From 5f94c42453f0ef45ae8d95be3ec91bf61906f911 Mon Sep 17 00:00:00 2001 From: christianesperar Date: Thu, 14 Jul 2016 00:34:04 +0800 Subject: [PATCH] Add Flot plugin to bower --- bower.json | 6 +- production/index.html | 9 +- production/index2.html | 9 +- production/index3.html | 9 +- production/js/flot/date.js | 104 - production/js/flot/jquery.flot.spline.js | 212 - vendors/DateJS/.bower.json | 35 + vendors/DateJS/GruntFile.js | 184 + vendors/DateJS/LICENSE | 21 + vendors/DateJS/README.md | 48 + vendors/DateJS/bower.json | 25 + vendors/DateJS/build/date-af-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-AE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-BH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-DZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-EG.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-IQ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-JO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-KW.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-LB.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-LY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-MA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-OM.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-QA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-SA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-SY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-TN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ar-YE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-az-Cyrl-AZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-az-Latn-AZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-be-BY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-bg-BG.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-bs-Latn-BA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ca-ES.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-cs-CZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-cy-GB.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-da-DK.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-de-AT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-de-CH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-de-DE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-de-LI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-de-LU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-dv-MV.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-el-GR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-029.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-AU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-BZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-CA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-GB.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-IE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-JM.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-NZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-PH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-TT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-US.js | 4096 +++++++++++++++ vendors/DateJS/build/date-en-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-en-ZW.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-AR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-BO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-CL.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-CO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-CR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-DO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-EC.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-ES.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-GT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-HN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-MX.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-NI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-PA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-PE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-PR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-PY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-SV.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-UY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-es-VE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-et-EE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-eu-ES.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fa-IR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fi-FI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fo-FO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-BE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-CA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-CH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-FR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-LU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-fr-MC.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-gl-ES.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-gu-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-he-IL.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-hi-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-hr-BA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-hr-HR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-hu-HU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-hy-AM.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-id-ID.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-is-IS.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-it-CH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-it-IT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ja-JP.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ka-GE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-kk-KZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-kn-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ko-KR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-kok-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ky-KG.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-lt-LT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-lv-LV.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-mi-NZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-mk-MK.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-mn-MN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-mr-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ms-BN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ms-MY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-mt-MT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-nb-NO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-nl-BE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-nl-NL.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-nn-NO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ns-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-pa-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-pl-PL.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-pt-BR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-pt-PT.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-quz-BO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-quz-EC.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-quz-PE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ro-RO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ru-RU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sa-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-se-FI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-se-NO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-se-SE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sk-SK.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sl-SI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sma-NO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sma-SE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-smj-NO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-smj-SE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-smn-FI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sms-FI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sq-AL.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sr-Cyrl-BA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sr-Cyrl-CS.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sr-Latn-BA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sr-Latn-CS.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sv-FI.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sv-SE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-sw-KE.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-syr-SY.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ta-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-te-IN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-th-TH.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-tn-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-tr-TR.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-tt-RU.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-uk-UA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-ur-PK.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-uz-Cyrl-UZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-uz-Latn-UZ.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-vi-VN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-xh-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zh-CN.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zh-HK.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zh-MO.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zh-SG.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zh-TW.js | 4526 +++++++++++++++++ vendors/DateJS/build/date-zu-ZA.js | 4526 +++++++++++++++++ vendors/DateJS/build/date.js | 4339 ++++++++++++++++ vendors/DateJS/build/i18n/af-ZA.js | 178 + vendors/DateJS/build/i18n/ar-AE.js | 178 + vendors/DateJS/build/i18n/ar-BH.js | 178 + vendors/DateJS/build/i18n/ar-DZ.js | 178 + vendors/DateJS/build/i18n/ar-EG.js | 178 + vendors/DateJS/build/i18n/ar-IQ.js | 178 + vendors/DateJS/build/i18n/ar-JO.js | 178 + vendors/DateJS/build/i18n/ar-KW.js | 178 + vendors/DateJS/build/i18n/ar-LB.js | 178 + vendors/DateJS/build/i18n/ar-LY.js | 178 + vendors/DateJS/build/i18n/ar-MA.js | 178 + vendors/DateJS/build/i18n/ar-OM.js | 178 + vendors/DateJS/build/i18n/ar-QA.js | 178 + vendors/DateJS/build/i18n/ar-SA.js | 178 + vendors/DateJS/build/i18n/ar-SY.js | 178 + vendors/DateJS/build/i18n/ar-TN.js | 178 + vendors/DateJS/build/i18n/ar-YE.js | 178 + vendors/DateJS/build/i18n/az-Cyrl-AZ.js | 178 + vendors/DateJS/build/i18n/az-Latn-AZ.js | 178 + vendors/DateJS/build/i18n/be-BY.js | 178 + vendors/DateJS/build/i18n/bg-BG.js | 178 + vendors/DateJS/build/i18n/bs-Latn-BA.js | 178 + vendors/DateJS/build/i18n/ca-ES.js | 178 + vendors/DateJS/build/i18n/cs-CZ.js | 178 + vendors/DateJS/build/i18n/cy-GB.js | 178 + vendors/DateJS/build/i18n/da-DK.js | 178 + vendors/DateJS/build/i18n/de-AT.js | 178 + vendors/DateJS/build/i18n/de-CH.js | 178 + vendors/DateJS/build/i18n/de-DE.js | 178 + vendors/DateJS/build/i18n/de-LI.js | 178 + vendors/DateJS/build/i18n/de-LU.js | 178 + vendors/DateJS/build/i18n/dv-MV.js | 178 + vendors/DateJS/build/i18n/el-GR.js | 178 + vendors/DateJS/build/i18n/en-029.js | 178 + vendors/DateJS/build/i18n/en-AU.js | 178 + vendors/DateJS/build/i18n/en-BZ.js | 178 + vendors/DateJS/build/i18n/en-CA.js | 178 + vendors/DateJS/build/i18n/en-GB.js | 178 + vendors/DateJS/build/i18n/en-IE.js | 178 + vendors/DateJS/build/i18n/en-JM.js | 178 + vendors/DateJS/build/i18n/en-NZ.js | 178 + vendors/DateJS/build/i18n/en-PH.js | 178 + vendors/DateJS/build/i18n/en-TT.js | 178 + vendors/DateJS/build/i18n/en-ZA.js | 178 + vendors/DateJS/build/i18n/en-ZW.js | 178 + vendors/DateJS/build/i18n/es-AR.js | 178 + vendors/DateJS/build/i18n/es-BO.js | 178 + vendors/DateJS/build/i18n/es-CL.js | 178 + vendors/DateJS/build/i18n/es-CO.js | 178 + vendors/DateJS/build/i18n/es-CR.js | 178 + vendors/DateJS/build/i18n/es-DO.js | 178 + vendors/DateJS/build/i18n/es-EC.js | 178 + vendors/DateJS/build/i18n/es-ES.js | 178 + vendors/DateJS/build/i18n/es-GT.js | 178 + vendors/DateJS/build/i18n/es-HN.js | 178 + vendors/DateJS/build/i18n/es-MX.js | 178 + vendors/DateJS/build/i18n/es-NI.js | 178 + vendors/DateJS/build/i18n/es-PA.js | 178 + vendors/DateJS/build/i18n/es-PE.js | 178 + vendors/DateJS/build/i18n/es-PR.js | 178 + vendors/DateJS/build/i18n/es-PY.js | 178 + vendors/DateJS/build/i18n/es-SV.js | 178 + vendors/DateJS/build/i18n/es-UY.js | 178 + vendors/DateJS/build/i18n/es-VE.js | 178 + vendors/DateJS/build/i18n/et-EE.js | 178 + vendors/DateJS/build/i18n/eu-ES.js | 178 + vendors/DateJS/build/i18n/fa-IR.js | 178 + vendors/DateJS/build/i18n/fi-FI.js | 178 + vendors/DateJS/build/i18n/fo-FO.js | 178 + vendors/DateJS/build/i18n/fr-BE.js | 178 + vendors/DateJS/build/i18n/fr-CA.js | 178 + vendors/DateJS/build/i18n/fr-CH.js | 178 + vendors/DateJS/build/i18n/fr-FR.js | 178 + vendors/DateJS/build/i18n/fr-LU.js | 178 + vendors/DateJS/build/i18n/fr-MC.js | 178 + vendors/DateJS/build/i18n/gl-ES.js | 178 + vendors/DateJS/build/i18n/gu-IN.js | 178 + vendors/DateJS/build/i18n/he-IL.js | 178 + vendors/DateJS/build/i18n/hi-IN.js | 178 + vendors/DateJS/build/i18n/hr-BA.js | 178 + vendors/DateJS/build/i18n/hr-HR.js | 178 + vendors/DateJS/build/i18n/hu-HU.js | 178 + vendors/DateJS/build/i18n/hy-AM.js | 178 + vendors/DateJS/build/i18n/id-ID.js | 178 + vendors/DateJS/build/i18n/is-IS.js | 178 + vendors/DateJS/build/i18n/it-CH.js | 178 + vendors/DateJS/build/i18n/it-IT.js | 178 + vendors/DateJS/build/i18n/ja-JP.js | 178 + vendors/DateJS/build/i18n/ka-GE.js | 178 + vendors/DateJS/build/i18n/kk-KZ.js | 178 + vendors/DateJS/build/i18n/kn-IN.js | 178 + vendors/DateJS/build/i18n/ko-KR.js | 178 + vendors/DateJS/build/i18n/kok-IN.js | 178 + vendors/DateJS/build/i18n/ky-KG.js | 178 + vendors/DateJS/build/i18n/lt-LT.js | 178 + vendors/DateJS/build/i18n/lv-LV.js | 178 + vendors/DateJS/build/i18n/mi-NZ.js | 178 + vendors/DateJS/build/i18n/mk-MK.js | 178 + vendors/DateJS/build/i18n/mn-MN.js | 178 + vendors/DateJS/build/i18n/mr-IN.js | 178 + vendors/DateJS/build/i18n/ms-BN.js | 178 + vendors/DateJS/build/i18n/ms-MY.js | 178 + vendors/DateJS/build/i18n/mt-MT.js | 178 + vendors/DateJS/build/i18n/nb-NO.js | 178 + vendors/DateJS/build/i18n/nl-BE.js | 178 + vendors/DateJS/build/i18n/nl-NL.js | 178 + vendors/DateJS/build/i18n/nn-NO.js | 178 + vendors/DateJS/build/i18n/ns-ZA.js | 178 + vendors/DateJS/build/i18n/pa-IN.js | 178 + vendors/DateJS/build/i18n/pl-PL.js | 178 + vendors/DateJS/build/i18n/pt-BR.js | 178 + vendors/DateJS/build/i18n/pt-PT.js | 178 + vendors/DateJS/build/i18n/quz-BO.js | 178 + vendors/DateJS/build/i18n/quz-EC.js | 178 + vendors/DateJS/build/i18n/quz-PE.js | 178 + vendors/DateJS/build/i18n/ro-RO.js | 178 + vendors/DateJS/build/i18n/ru-RU.js | 178 + vendors/DateJS/build/i18n/sa-IN.js | 178 + vendors/DateJS/build/i18n/se-FI.js | 178 + vendors/DateJS/build/i18n/se-NO.js | 178 + vendors/DateJS/build/i18n/se-SE.js | 178 + vendors/DateJS/build/i18n/sk-SK.js | 178 + vendors/DateJS/build/i18n/sl-SI.js | 178 + vendors/DateJS/build/i18n/sma-NO.js | 178 + vendors/DateJS/build/i18n/sma-SE.js | 178 + vendors/DateJS/build/i18n/smj-NO.js | 178 + vendors/DateJS/build/i18n/smj-SE.js | 178 + vendors/DateJS/build/i18n/smn-FI.js | 178 + vendors/DateJS/build/i18n/sms-FI.js | 178 + vendors/DateJS/build/i18n/sq-AL.js | 178 + vendors/DateJS/build/i18n/sr-Cyrl-BA.js | 178 + vendors/DateJS/build/i18n/sr-Cyrl-CS.js | 178 + vendors/DateJS/build/i18n/sr-Latn-BA.js | 178 + vendors/DateJS/build/i18n/sr-Latn-CS.js | 178 + vendors/DateJS/build/i18n/sv-FI.js | 178 + vendors/DateJS/build/i18n/sv-SE.js | 178 + vendors/DateJS/build/i18n/sw-KE.js | 178 + vendors/DateJS/build/i18n/syr-SY.js | 178 + vendors/DateJS/build/i18n/ta-IN.js | 178 + vendors/DateJS/build/i18n/te-IN.js | 178 + vendors/DateJS/build/i18n/th-TH.js | 178 + vendors/DateJS/build/i18n/tn-ZA.js | 178 + vendors/DateJS/build/i18n/tr-TR.js | 178 + vendors/DateJS/build/i18n/tt-RU.js | 178 + vendors/DateJS/build/i18n/uk-UA.js | 178 + vendors/DateJS/build/i18n/ur-PK.js | 178 + vendors/DateJS/build/i18n/uz-Cyrl-UZ.js | 178 + vendors/DateJS/build/i18n/uz-Latn-UZ.js | 178 + vendors/DateJS/build/i18n/vi-VN.js | 178 + vendors/DateJS/build/i18n/xh-ZA.js | 178 + vendors/DateJS/build/i18n/zh-CN.js | 178 + vendors/DateJS/build/i18n/zh-HK.js | 178 + vendors/DateJS/build/i18n/zh-MO.js | 178 + vendors/DateJS/build/i18n/zh-SG.js | 178 + vendors/DateJS/build/i18n/zh-TW.js | 178 + vendors/DateJS/build/i18n/zu-ZA.js | 178 + .../DateJS/build/production/date-af-ZA.min.js | 134 + .../DateJS/build/production/date-ar-AE.min.js | 137 + .../DateJS/build/production/date-ar-BH.min.js | 137 + .../DateJS/build/production/date-ar-DZ.min.js | 137 + .../DateJS/build/production/date-ar-EG.min.js | 137 + .../DateJS/build/production/date-ar-IQ.min.js | 138 + .../DateJS/build/production/date-ar-JO.min.js | 138 + .../DateJS/build/production/date-ar-KW.min.js | 137 + .../DateJS/build/production/date-ar-LB.min.js | 138 + .../DateJS/build/production/date-ar-LY.min.js | 137 + .../DateJS/build/production/date-ar-MA.min.js | 137 + .../DateJS/build/production/date-ar-OM.min.js | 137 + .../DateJS/build/production/date-ar-QA.min.js | 137 + .../DateJS/build/production/date-ar-SA.min.js | 138 + .../DateJS/build/production/date-ar-SY.min.js | 138 + .../DateJS/build/production/date-ar-TN.min.js | 137 + .../DateJS/build/production/date-ar-YE.min.js | 137 + .../build/production/date-az-Cyrl-AZ.min.js | 137 + .../build/production/date-az-Latn-AZ.min.js | 135 + .../DateJS/build/production/date-be-BY.min.js | 137 + .../DateJS/build/production/date-bg-BG.min.js | 138 + .../build/production/date-bs-Latn-BA.min.js | 134 + .../DateJS/build/production/date-ca-ES.min.js | 134 + .../DateJS/build/production/date-cs-CZ.min.js | 134 + .../DateJS/build/production/date-cy-GB.min.js | 134 + .../DateJS/build/production/date-da-DK.min.js | 134 + .../DateJS/build/production/date-de-AT.min.js | 134 + .../DateJS/build/production/date-de-CH.min.js | 134 + .../DateJS/build/production/date-de-DE.min.js | 134 + .../DateJS/build/production/date-de-LI.min.js | 134 + .../DateJS/build/production/date-de-LU.min.js | 134 + .../DateJS/build/production/date-dv-MV.min.js | 138 + .../DateJS/build/production/date-el-GR.min.js | 138 + .../build/production/date-en-029.min.js | 134 + .../DateJS/build/production/date-en-AU.min.js | 134 + .../DateJS/build/production/date-en-BZ.min.js | 134 + .../DateJS/build/production/date-en-CA.min.js | 134 + .../DateJS/build/production/date-en-GB.min.js | 134 + .../DateJS/build/production/date-en-IE.min.js | 134 + .../DateJS/build/production/date-en-JM.min.js | 134 + .../DateJS/build/production/date-en-NZ.min.js | 134 + .../DateJS/build/production/date-en-PH.min.js | 134 + .../DateJS/build/production/date-en-TT.min.js | 134 + .../DateJS/build/production/date-en-US.min.js | 125 + .../DateJS/build/production/date-en-ZA.min.js | 134 + .../DateJS/build/production/date-en-ZW.min.js | 134 + .../DateJS/build/production/date-es-AR.min.js | 134 + .../DateJS/build/production/date-es-BO.min.js | 134 + .../DateJS/build/production/date-es-CL.min.js | 134 + .../DateJS/build/production/date-es-CO.min.js | 134 + .../DateJS/build/production/date-es-CR.min.js | 134 + .../DateJS/build/production/date-es-DO.min.js | 134 + .../DateJS/build/production/date-es-EC.min.js | 134 + .../DateJS/build/production/date-es-ES.min.js | 134 + .../DateJS/build/production/date-es-GT.min.js | 134 + .../DateJS/build/production/date-es-HN.min.js | 134 + .../DateJS/build/production/date-es-MX.min.js | 134 + .../DateJS/build/production/date-es-NI.min.js | 134 + .../DateJS/build/production/date-es-PA.min.js | 134 + .../DateJS/build/production/date-es-PE.min.js | 134 + .../DateJS/build/production/date-es-PR.min.js | 134 + .../DateJS/build/production/date-es-PY.min.js | 134 + .../DateJS/build/production/date-es-SV.min.js | 134 + .../DateJS/build/production/date-es-UY.min.js | 134 + .../DateJS/build/production/date-es-VE.min.js | 134 + .../DateJS/build/production/date-et-EE.min.js | 134 + .../DateJS/build/production/date-eu-ES.min.js | 134 + .../DateJS/build/production/date-fa-IR.min.js | 134 + .../DateJS/build/production/date-fi-FI.min.js | 134 + .../DateJS/build/production/date-fo-FO.min.js | 134 + .../DateJS/build/production/date-fr-BE.min.js | 134 + .../DateJS/build/production/date-fr-CA.min.js | 134 + .../DateJS/build/production/date-fr-CH.min.js | 134 + .../DateJS/build/production/date-fr-FR.min.js | 134 + .../DateJS/build/production/date-fr-LU.min.js | 134 + .../DateJS/build/production/date-fr-MC.min.js | 134 + .../DateJS/build/production/date-gl-ES.min.js | 134 + .../DateJS/build/production/date-gu-IN.min.js | 138 + .../DateJS/build/production/date-he-IL.min.js | 137 + .../DateJS/build/production/date-hi-IN.min.js | 137 + .../DateJS/build/production/date-hr-BA.min.js | 134 + .../DateJS/build/production/date-hr-HR.min.js | 134 + .../DateJS/build/production/date-hu-HU.min.js | 135 + .../DateJS/build/production/date-hy-AM.min.js | 137 + .../DateJS/build/production/date-id-ID.min.js | 134 + .../DateJS/build/production/date-is-IS.min.js | 135 + .../DateJS/build/production/date-it-CH.min.js | 134 + .../DateJS/build/production/date-it-IT.min.js | 134 + .../DateJS/build/production/date-ja-JP.min.js | 135 + .../DateJS/build/production/date-ka-GE.min.js | 137 + .../DateJS/build/production/date-kk-KZ.min.js | 137 + .../DateJS/build/production/date-kn-IN.min.js | 138 + .../DateJS/build/production/date-ko-KR.min.js | 135 + .../build/production/date-kok-IN.min.js | 137 + .../DateJS/build/production/date-ky-KG.min.js | 137 + .../DateJS/build/production/date-lt-LT.min.js | 135 + .../DateJS/build/production/date-lv-LV.min.js | 134 + .../DateJS/build/production/date-mi-NZ.min.js | 135 + .../DateJS/build/production/date-mk-MK.min.js | 138 + .../DateJS/build/production/date-mn-MN.min.js | 138 + .../DateJS/build/production/date-mr-IN.min.js | 138 + .../DateJS/build/production/date-ms-BN.min.js | 134 + .../DateJS/build/production/date-ms-MY.min.js | 134 + .../DateJS/build/production/date-mt-MT.min.js | 134 + .../DateJS/build/production/date-nb-NO.min.js | 134 + .../DateJS/build/production/date-nl-BE.min.js | 134 + .../DateJS/build/production/date-nl-NL.min.js | 134 + .../DateJS/build/production/date-nn-NO.min.js | 134 + .../DateJS/build/production/date-ns-ZA.min.js | 134 + .../DateJS/build/production/date-pa-IN.min.js | 137 + .../DateJS/build/production/date-pl-PL.min.js | 134 + .../DateJS/build/production/date-pt-BR.min.js | 134 + .../DateJS/build/production/date-pt-PT.min.js | 134 + .../build/production/date-quz-BO.min.js | 134 + .../build/production/date-quz-EC.min.js | 134 + .../build/production/date-quz-PE.min.js | 134 + .../DateJS/build/production/date-ro-RO.min.js | 134 + .../DateJS/build/production/date-ru-RU.min.js | 138 + .../DateJS/build/production/date-sa-IN.min.js | 137 + .../DateJS/build/production/date-se-FI.min.js | 135 + .../DateJS/build/production/date-se-NO.min.js | 135 + .../DateJS/build/production/date-se-SE.min.js | 135 + .../DateJS/build/production/date-sk-SK.min.js | 134 + .../DateJS/build/production/date-sl-SI.min.js | 134 + .../build/production/date-sma-NO.min.js | 135 + .../build/production/date-sma-SE.min.js | 135 + .../build/production/date-smj-NO.min.js | 135 + .../build/production/date-smj-SE.min.js | 135 + .../build/production/date-smn-FI.min.js | 135 + .../build/production/date-sms-FI.min.js | 136 + .../DateJS/build/production/date-sq-AL.min.js | 134 + .../build/production/date-sr-Cyrl-BA.min.js | 137 + .../build/production/date-sr-Cyrl-CS.min.js | 137 + .../build/production/date-sr-Latn-BA.min.js | 134 + .../build/production/date-sr-Latn-CS.min.js | 134 + .../DateJS/build/production/date-sv-FI.min.js | 134 + .../DateJS/build/production/date-sv-SE.min.js | 134 + .../DateJS/build/production/date-sw-KE.min.js | 134 + .../build/production/date-syr-SY.min.js | 137 + .../DateJS/build/production/date-ta-IN.min.js | 137 + .../DateJS/build/production/date-te-IN.min.js | 138 + .../DateJS/build/production/date-th-TH.min.js | 137 + .../DateJS/build/production/date-tn-ZA.min.js | 134 + .../DateJS/build/production/date-tr-TR.min.js | 134 + .../DateJS/build/production/date-tt-RU.min.js | 137 + .../DateJS/build/production/date-uk-UA.min.js | 137 + .../DateJS/build/production/date-ur-PK.min.js | 136 + .../build/production/date-uz-Cyrl-UZ.min.js | 137 + .../build/production/date-uz-Latn-UZ.min.js | 134 + .../DateJS/build/production/date-vi-VN.min.js | 135 + .../DateJS/build/production/date-xh-ZA.min.js | 134 + .../DateJS/build/production/date-zh-CN.min.js | 135 + .../DateJS/build/production/date-zh-HK.min.js | 134 + .../DateJS/build/production/date-zh-MO.min.js | 135 + .../DateJS/build/production/date-zh-SG.min.js | 135 + .../DateJS/build/production/date-zh-TW.min.js | 135 + .../DateJS/build/production/date-zu-ZA.min.js | 134 + vendors/DateJS/build/production/date.min.js | 123 + vendors/DateJS/build/production/i18n/af-ZA.js | 178 + vendors/DateJS/build/production/i18n/ar-AE.js | 178 + vendors/DateJS/build/production/i18n/ar-BH.js | 178 + vendors/DateJS/build/production/i18n/ar-DZ.js | 178 + vendors/DateJS/build/production/i18n/ar-EG.js | 178 + vendors/DateJS/build/production/i18n/ar-IQ.js | 178 + vendors/DateJS/build/production/i18n/ar-JO.js | 178 + vendors/DateJS/build/production/i18n/ar-KW.js | 178 + vendors/DateJS/build/production/i18n/ar-LB.js | 178 + vendors/DateJS/build/production/i18n/ar-LY.js | 178 + vendors/DateJS/build/production/i18n/ar-MA.js | 178 + vendors/DateJS/build/production/i18n/ar-OM.js | 178 + vendors/DateJS/build/production/i18n/ar-QA.js | 178 + vendors/DateJS/build/production/i18n/ar-SA.js | 178 + vendors/DateJS/build/production/i18n/ar-SY.js | 178 + vendors/DateJS/build/production/i18n/ar-TN.js | 178 + vendors/DateJS/build/production/i18n/ar-YE.js | 178 + .../build/production/i18n/az-Cyrl-AZ.js | 178 + .../build/production/i18n/az-Latn-AZ.js | 178 + vendors/DateJS/build/production/i18n/be-BY.js | 178 + vendors/DateJS/build/production/i18n/bg-BG.js | 178 + .../build/production/i18n/bs-Latn-BA.js | 178 + vendors/DateJS/build/production/i18n/ca-ES.js | 178 + vendors/DateJS/build/production/i18n/cs-CZ.js | 178 + vendors/DateJS/build/production/i18n/cy-GB.js | 178 + vendors/DateJS/build/production/i18n/da-DK.js | 178 + vendors/DateJS/build/production/i18n/de-AT.js | 178 + vendors/DateJS/build/production/i18n/de-CH.js | 178 + vendors/DateJS/build/production/i18n/de-DE.js | 178 + vendors/DateJS/build/production/i18n/de-LI.js | 178 + vendors/DateJS/build/production/i18n/de-LU.js | 178 + vendors/DateJS/build/production/i18n/dv-MV.js | 178 + vendors/DateJS/build/production/i18n/el-GR.js | 178 + .../DateJS/build/production/i18n/en-029.js | 178 + vendors/DateJS/build/production/i18n/en-AU.js | 178 + vendors/DateJS/build/production/i18n/en-BZ.js | 178 + vendors/DateJS/build/production/i18n/en-CA.js | 178 + vendors/DateJS/build/production/i18n/en-GB.js | 178 + vendors/DateJS/build/production/i18n/en-IE.js | 178 + vendors/DateJS/build/production/i18n/en-JM.js | 178 + vendors/DateJS/build/production/i18n/en-NZ.js | 178 + vendors/DateJS/build/production/i18n/en-PH.js | 178 + vendors/DateJS/build/production/i18n/en-TT.js | 178 + vendors/DateJS/build/production/i18n/en-ZA.js | 178 + vendors/DateJS/build/production/i18n/en-ZW.js | 178 + vendors/DateJS/build/production/i18n/es-AR.js | 178 + vendors/DateJS/build/production/i18n/es-BO.js | 178 + vendors/DateJS/build/production/i18n/es-CL.js | 178 + vendors/DateJS/build/production/i18n/es-CO.js | 178 + vendors/DateJS/build/production/i18n/es-CR.js | 178 + vendors/DateJS/build/production/i18n/es-DO.js | 178 + vendors/DateJS/build/production/i18n/es-EC.js | 178 + vendors/DateJS/build/production/i18n/es-ES.js | 178 + vendors/DateJS/build/production/i18n/es-GT.js | 178 + vendors/DateJS/build/production/i18n/es-HN.js | 178 + vendors/DateJS/build/production/i18n/es-MX.js | 178 + vendors/DateJS/build/production/i18n/es-NI.js | 178 + vendors/DateJS/build/production/i18n/es-PA.js | 178 + vendors/DateJS/build/production/i18n/es-PE.js | 178 + vendors/DateJS/build/production/i18n/es-PR.js | 178 + vendors/DateJS/build/production/i18n/es-PY.js | 178 + vendors/DateJS/build/production/i18n/es-SV.js | 178 + vendors/DateJS/build/production/i18n/es-UY.js | 178 + vendors/DateJS/build/production/i18n/es-VE.js | 178 + vendors/DateJS/build/production/i18n/et-EE.js | 178 + vendors/DateJS/build/production/i18n/eu-ES.js | 178 + vendors/DateJS/build/production/i18n/fa-IR.js | 178 + vendors/DateJS/build/production/i18n/fi-FI.js | 178 + vendors/DateJS/build/production/i18n/fo-FO.js | 178 + vendors/DateJS/build/production/i18n/fr-BE.js | 178 + vendors/DateJS/build/production/i18n/fr-CA.js | 178 + vendors/DateJS/build/production/i18n/fr-CH.js | 178 + vendors/DateJS/build/production/i18n/fr-FR.js | 178 + vendors/DateJS/build/production/i18n/fr-LU.js | 178 + vendors/DateJS/build/production/i18n/fr-MC.js | 178 + vendors/DateJS/build/production/i18n/gl-ES.js | 178 + vendors/DateJS/build/production/i18n/gu-IN.js | 178 + vendors/DateJS/build/production/i18n/he-IL.js | 178 + vendors/DateJS/build/production/i18n/hi-IN.js | 178 + vendors/DateJS/build/production/i18n/hr-BA.js | 178 + vendors/DateJS/build/production/i18n/hr-HR.js | 178 + vendors/DateJS/build/production/i18n/hu-HU.js | 178 + vendors/DateJS/build/production/i18n/hy-AM.js | 178 + vendors/DateJS/build/production/i18n/id-ID.js | 178 + vendors/DateJS/build/production/i18n/is-IS.js | 178 + vendors/DateJS/build/production/i18n/it-CH.js | 178 + vendors/DateJS/build/production/i18n/it-IT.js | 178 + vendors/DateJS/build/production/i18n/ja-JP.js | 178 + vendors/DateJS/build/production/i18n/ka-GE.js | 178 + vendors/DateJS/build/production/i18n/kk-KZ.js | 178 + vendors/DateJS/build/production/i18n/kn-IN.js | 178 + vendors/DateJS/build/production/i18n/ko-KR.js | 178 + .../DateJS/build/production/i18n/kok-IN.js | 178 + vendors/DateJS/build/production/i18n/ky-KG.js | 178 + vendors/DateJS/build/production/i18n/lt-LT.js | 178 + vendors/DateJS/build/production/i18n/lv-LV.js | 178 + vendors/DateJS/build/production/i18n/mi-NZ.js | 178 + vendors/DateJS/build/production/i18n/mk-MK.js | 178 + vendors/DateJS/build/production/i18n/mn-MN.js | 178 + vendors/DateJS/build/production/i18n/mr-IN.js | 178 + vendors/DateJS/build/production/i18n/ms-BN.js | 178 + vendors/DateJS/build/production/i18n/ms-MY.js | 178 + vendors/DateJS/build/production/i18n/mt-MT.js | 178 + vendors/DateJS/build/production/i18n/nb-NO.js | 178 + vendors/DateJS/build/production/i18n/nl-BE.js | 178 + vendors/DateJS/build/production/i18n/nl-NL.js | 178 + vendors/DateJS/build/production/i18n/nn-NO.js | 178 + vendors/DateJS/build/production/i18n/ns-ZA.js | 178 + vendors/DateJS/build/production/i18n/pa-IN.js | 178 + vendors/DateJS/build/production/i18n/pl-PL.js | 178 + vendors/DateJS/build/production/i18n/pt-BR.js | 178 + vendors/DateJS/build/production/i18n/pt-PT.js | 178 + .../DateJS/build/production/i18n/quz-BO.js | 178 + .../DateJS/build/production/i18n/quz-EC.js | 178 + .../DateJS/build/production/i18n/quz-PE.js | 178 + vendors/DateJS/build/production/i18n/ro-RO.js | 178 + vendors/DateJS/build/production/i18n/ru-RU.js | 178 + vendors/DateJS/build/production/i18n/sa-IN.js | 178 + vendors/DateJS/build/production/i18n/se-FI.js | 178 + vendors/DateJS/build/production/i18n/se-NO.js | 178 + vendors/DateJS/build/production/i18n/se-SE.js | 178 + vendors/DateJS/build/production/i18n/sk-SK.js | 178 + vendors/DateJS/build/production/i18n/sl-SI.js | 178 + .../DateJS/build/production/i18n/sma-NO.js | 178 + .../DateJS/build/production/i18n/sma-SE.js | 178 + .../DateJS/build/production/i18n/smj-NO.js | 178 + .../DateJS/build/production/i18n/smj-SE.js | 178 + .../DateJS/build/production/i18n/smn-FI.js | 178 + .../DateJS/build/production/i18n/sms-FI.js | 178 + vendors/DateJS/build/production/i18n/sq-AL.js | 178 + .../build/production/i18n/sr-Cyrl-BA.js | 178 + .../build/production/i18n/sr-Cyrl-CS.js | 178 + .../build/production/i18n/sr-Latn-BA.js | 178 + .../build/production/i18n/sr-Latn-CS.js | 178 + vendors/DateJS/build/production/i18n/sv-FI.js | 178 + vendors/DateJS/build/production/i18n/sv-SE.js | 178 + vendors/DateJS/build/production/i18n/sw-KE.js | 178 + .../DateJS/build/production/i18n/syr-SY.js | 178 + vendors/DateJS/build/production/i18n/ta-IN.js | 178 + vendors/DateJS/build/production/i18n/te-IN.js | 178 + vendors/DateJS/build/production/i18n/th-TH.js | 178 + vendors/DateJS/build/production/i18n/tn-ZA.js | 178 + vendors/DateJS/build/production/i18n/tr-TR.js | 178 + vendors/DateJS/build/production/i18n/tt-RU.js | 178 + vendors/DateJS/build/production/i18n/uk-UA.js | 178 + vendors/DateJS/build/production/i18n/ur-PK.js | 178 + .../build/production/i18n/uz-Cyrl-UZ.js | 178 + .../build/production/i18n/uz-Latn-UZ.js | 178 + vendors/DateJS/build/production/i18n/vi-VN.js | 178 + vendors/DateJS/build/production/i18n/xh-ZA.js | 178 + vendors/DateJS/build/production/i18n/zh-CN.js | 178 + vendors/DateJS/build/production/i18n/zh-HK.js | 178 + vendors/DateJS/build/production/i18n/zh-MO.js | 178 + vendors/DateJS/build/production/i18n/zh-SG.js | 178 + vendors/DateJS/build/production/i18n/zh-TW.js | 178 + vendors/DateJS/build/production/i18n/zu-ZA.js | 178 + vendors/DateJS/index.js | 19 + vendors/DateJS/package.json | 52 + vendors/DateJS/reports/coverage.json | 1 + .../lcov-report/core/core-prototypes.js.html | 2626 ++++++++++ .../reports/lcov-report/core/core.js.html | 1351 +++++ .../reports/lcov-report/core/extras.js.html | 1261 +++++ .../lcov-report/core/format_parser.js.html | 1462 ++++++ .../reports/lcov-report/core/i18n.js.html | 1567 ++++++ .../reports/lcov-report/core/index.html | 493 ++ .../reports/lcov-report/core/parser.js.html | 940 ++++ .../lcov-report/core/parsing_grammar.js.html | 1249 +++++ .../core/parsing_operators.js.html | 1693 ++++++ .../core/parsing_translator.js.html | 1405 +++++ .../reports/lcov-report/core/sugarpak.js.html | 1801 +++++++ .../lcov-report/core/time_period.js.html | 622 +++ .../lcov-report/core/time_span.js.html | 847 +++ vendors/DateJS/reports/lcov-report/index.html | 350 ++ .../DateJS/reports/lcov-report/prettify.css | 1 + .../DateJS/reports/lcov-report/prettify.js | 1 + vendors/DateJS/reports/lcov.info | 3590 +++++++++++++ vendors/DateJS/src/core/core-prototypes.js | 769 +++ vendors/DateJS/src/core/core.js | 343 ++ vendors/DateJS/src/core/extras.js | 314 ++ vendors/DateJS/src/core/format_parser.js | 381 ++ vendors/DateJS/src/core/i18n.js | 416 ++ vendors/DateJS/src/core/parser.js | 206 + vendors/DateJS/src/core/parsing_grammar.js | 310 ++ vendors/DateJS/src/core/parsing_operators.js | 458 ++ vendors/DateJS/src/core/parsing_translator.js | 362 ++ vendors/DateJS/src/core/sugarpak.js | 493 ++ vendors/DateJS/src/core/time_period.js | 101 + vendors/DateJS/src/core/time_span.js | 176 + vendors/DateJS/src/i18n-template.js | 178 + vendors/DateJS/src/i18n/af-ZA.js | 178 + vendors/DateJS/src/i18n/ar-AE.js | 178 + vendors/DateJS/src/i18n/ar-BH.js | 178 + vendors/DateJS/src/i18n/ar-DZ.js | 178 + vendors/DateJS/src/i18n/ar-EG.js | 178 + vendors/DateJS/src/i18n/ar-IQ.js | 178 + vendors/DateJS/src/i18n/ar-JO.js | 178 + vendors/DateJS/src/i18n/ar-KW.js | 178 + vendors/DateJS/src/i18n/ar-LB.js | 178 + vendors/DateJS/src/i18n/ar-LY.js | 178 + vendors/DateJS/src/i18n/ar-MA.js | 178 + vendors/DateJS/src/i18n/ar-OM.js | 178 + vendors/DateJS/src/i18n/ar-QA.js | 178 + vendors/DateJS/src/i18n/ar-SA.js | 178 + vendors/DateJS/src/i18n/ar-SY.js | 178 + vendors/DateJS/src/i18n/ar-TN.js | 178 + vendors/DateJS/src/i18n/ar-YE.js | 178 + vendors/DateJS/src/i18n/az-Cyrl-AZ.js | 178 + vendors/DateJS/src/i18n/az-Latn-AZ.js | 178 + vendors/DateJS/src/i18n/be-BY.js | 178 + vendors/DateJS/src/i18n/bg-BG.js | 178 + vendors/DateJS/src/i18n/bs-Latn-BA.js | 178 + vendors/DateJS/src/i18n/ca-ES.js | 178 + vendors/DateJS/src/i18n/cs-CZ.js | 178 + vendors/DateJS/src/i18n/cy-GB.js | 178 + vendors/DateJS/src/i18n/da-DK.js | 178 + vendors/DateJS/src/i18n/de-AT.js | 178 + vendors/DateJS/src/i18n/de-CH.js | 178 + vendors/DateJS/src/i18n/de-DE.js | 178 + vendors/DateJS/src/i18n/de-LI.js | 178 + vendors/DateJS/src/i18n/de-LU.js | 178 + vendors/DateJS/src/i18n/dv-MV.js | 178 + vendors/DateJS/src/i18n/el-GR.js | 178 + vendors/DateJS/src/i18n/en-029.js | 178 + vendors/DateJS/src/i18n/en-AU.js | 178 + vendors/DateJS/src/i18n/en-BZ.js | 178 + vendors/DateJS/src/i18n/en-CA.js | 178 + vendors/DateJS/src/i18n/en-GB.js | 178 + vendors/DateJS/src/i18n/en-IE.js | 178 + vendors/DateJS/src/i18n/en-JM.js | 178 + vendors/DateJS/src/i18n/en-NZ.js | 178 + vendors/DateJS/src/i18n/en-PH.js | 178 + vendors/DateJS/src/i18n/en-TT.js | 178 + vendors/DateJS/src/i18n/en-ZA.js | 178 + vendors/DateJS/src/i18n/en-ZW.js | 178 + vendors/DateJS/src/i18n/es-AR.js | 178 + vendors/DateJS/src/i18n/es-BO.js | 178 + vendors/DateJS/src/i18n/es-CL.js | 178 + vendors/DateJS/src/i18n/es-CO.js | 178 + vendors/DateJS/src/i18n/es-CR.js | 178 + vendors/DateJS/src/i18n/es-DO.js | 178 + vendors/DateJS/src/i18n/es-EC.js | 178 + vendors/DateJS/src/i18n/es-ES.js | 178 + vendors/DateJS/src/i18n/es-GT.js | 178 + vendors/DateJS/src/i18n/es-HN.js | 178 + vendors/DateJS/src/i18n/es-MX.js | 178 + vendors/DateJS/src/i18n/es-NI.js | 178 + vendors/DateJS/src/i18n/es-PA.js | 178 + vendors/DateJS/src/i18n/es-PE.js | 178 + vendors/DateJS/src/i18n/es-PR.js | 178 + vendors/DateJS/src/i18n/es-PY.js | 178 + vendors/DateJS/src/i18n/es-SV.js | 178 + vendors/DateJS/src/i18n/es-UY.js | 178 + vendors/DateJS/src/i18n/es-VE.js | 178 + vendors/DateJS/src/i18n/et-EE.js | 178 + vendors/DateJS/src/i18n/eu-ES.js | 178 + vendors/DateJS/src/i18n/fa-IR.js | 178 + vendors/DateJS/src/i18n/fi-FI.js | 178 + vendors/DateJS/src/i18n/fo-FO.js | 178 + vendors/DateJS/src/i18n/fr-BE.js | 178 + vendors/DateJS/src/i18n/fr-CA.js | 178 + vendors/DateJS/src/i18n/fr-CH.js | 178 + vendors/DateJS/src/i18n/fr-FR.js | 178 + vendors/DateJS/src/i18n/fr-LU.js | 178 + vendors/DateJS/src/i18n/fr-MC.js | 178 + vendors/DateJS/src/i18n/gl-ES.js | 178 + vendors/DateJS/src/i18n/gu-IN.js | 178 + vendors/DateJS/src/i18n/he-IL.js | 178 + vendors/DateJS/src/i18n/hi-IN.js | 178 + vendors/DateJS/src/i18n/hr-BA.js | 178 + vendors/DateJS/src/i18n/hr-HR.js | 178 + vendors/DateJS/src/i18n/hu-HU.js | 178 + vendors/DateJS/src/i18n/hy-AM.js | 178 + vendors/DateJS/src/i18n/id-ID.js | 178 + vendors/DateJS/src/i18n/is-IS.js | 178 + vendors/DateJS/src/i18n/it-CH.js | 178 + vendors/DateJS/src/i18n/it-IT.js | 178 + vendors/DateJS/src/i18n/ja-JP.js | 178 + vendors/DateJS/src/i18n/ka-GE.js | 178 + vendors/DateJS/src/i18n/kk-KZ.js | 178 + vendors/DateJS/src/i18n/kn-IN.js | 178 + vendors/DateJS/src/i18n/ko-KR.js | 178 + vendors/DateJS/src/i18n/kok-IN.js | 178 + vendors/DateJS/src/i18n/ky-KG.js | 178 + vendors/DateJS/src/i18n/lt-LT.js | 178 + vendors/DateJS/src/i18n/lv-LV.js | 178 + vendors/DateJS/src/i18n/mi-NZ.js | 178 + vendors/DateJS/src/i18n/mk-MK.js | 178 + vendors/DateJS/src/i18n/mn-MN.js | 178 + vendors/DateJS/src/i18n/mr-IN.js | 178 + vendors/DateJS/src/i18n/ms-BN.js | 178 + vendors/DateJS/src/i18n/ms-MY.js | 178 + vendors/DateJS/src/i18n/mt-MT.js | 178 + vendors/DateJS/src/i18n/nb-NO.js | 178 + vendors/DateJS/src/i18n/nl-BE.js | 178 + vendors/DateJS/src/i18n/nl-NL.js | 178 + vendors/DateJS/src/i18n/nn-NO.js | 178 + vendors/DateJS/src/i18n/ns-ZA.js | 178 + vendors/DateJS/src/i18n/pa-IN.js | 178 + vendors/DateJS/src/i18n/pl-PL.js | 178 + vendors/DateJS/src/i18n/pt-BR.js | 178 + vendors/DateJS/src/i18n/pt-PT.js | 178 + vendors/DateJS/src/i18n/quz-BO.js | 178 + vendors/DateJS/src/i18n/quz-EC.js | 178 + vendors/DateJS/src/i18n/quz-PE.js | 178 + vendors/DateJS/src/i18n/ro-RO.js | 178 + vendors/DateJS/src/i18n/ru-RU.js | 178 + vendors/DateJS/src/i18n/sa-IN.js | 178 + vendors/DateJS/src/i18n/se-FI.js | 178 + vendors/DateJS/src/i18n/se-NO.js | 178 + vendors/DateJS/src/i18n/se-SE.js | 178 + vendors/DateJS/src/i18n/sk-SK.js | 178 + vendors/DateJS/src/i18n/sl-SI.js | 178 + vendors/DateJS/src/i18n/sma-NO.js | 178 + vendors/DateJS/src/i18n/sma-SE.js | 178 + vendors/DateJS/src/i18n/smj-NO.js | 178 + vendors/DateJS/src/i18n/smj-SE.js | 178 + vendors/DateJS/src/i18n/smn-FI.js | 178 + vendors/DateJS/src/i18n/sms-FI.js | 178 + vendors/DateJS/src/i18n/sq-AL.js | 178 + vendors/DateJS/src/i18n/sr-Cyrl-BA.js | 178 + vendors/DateJS/src/i18n/sr-Cyrl-CS.js | 178 + vendors/DateJS/src/i18n/sr-Latn-BA.js | 178 + vendors/DateJS/src/i18n/sr-Latn-CS.js | 178 + vendors/DateJS/src/i18n/sv-FI.js | 178 + vendors/DateJS/src/i18n/sv-SE.js | 178 + vendors/DateJS/src/i18n/sw-KE.js | 178 + vendors/DateJS/src/i18n/syr-SY.js | 178 + vendors/DateJS/src/i18n/ta-IN.js | 178 + vendors/DateJS/src/i18n/te-IN.js | 178 + vendors/DateJS/src/i18n/th-TH.js | 178 + vendors/DateJS/src/i18n/tn-ZA.js | 178 + vendors/DateJS/src/i18n/tr-TR.js | 178 + vendors/DateJS/src/i18n/tt-RU.js | 178 + vendors/DateJS/src/i18n/uk-UA.js | 178 + vendors/DateJS/src/i18n/ur-PK.js | 178 + vendors/DateJS/src/i18n/uz-Cyrl-UZ.js | 178 + vendors/DateJS/src/i18n/uz-Latn-UZ.js | 178 + vendors/DateJS/src/i18n/vi-VN.js | 178 + vendors/DateJS/src/i18n/xh-ZA.js | 178 + vendors/DateJS/src/i18n/zh-CN.js | 178 + vendors/DateJS/src/i18n/zh-HK.js | 178 + vendors/DateJS/src/i18n/zh-MO.js | 178 + vendors/DateJS/src/i18n/zh-SG.js | 178 + vendors/DateJS/src/i18n/zh-TW.js | 178 + vendors/DateJS/src/i18n/zu-ZA.js | 178 + vendors/Flot/.bower.json | 2 +- vendors/flot-spline/.bower.json | 33 + vendors/flot-spline/LICENSE | 22 + vendors/flot-spline/bower.json | 23 + vendors/flot-spline/js/jquery.flot.spline.js | 212 + .../flot-spline/js/jquery.flot.spline.min.js | 1 + vendors/flot-spline/package.json | 13 + vendors/flot.curvedlines/.bower.json | 28 + vendors/flot.curvedlines/bower.json | 16 + .../flot.curvedlines}/curvedLines.js | 0 vendors/flot.orderbars/.bower.json | 14 + vendors/flot.orderbars/README.md | 36 + vendors/flot.orderbars/examples/index.html | 22 + .../flot.orderbars/examples/js/flot/flot.js | 2635 ++++++++++ .../flot.orderbars/examples/js/flot/stack.js | 188 + vendors/flot.orderbars/examples/js/main.js | 80 + .../examples/js/vendor/jquery-1.9.1.min.js | 5 + .../js}/jquery.flot.orderBars.js | 0 846 files changed, 848621 insertions(+), 330 deletions(-) delete mode 100755 production/js/flot/date.js delete mode 100755 production/js/flot/jquery.flot.spline.js create mode 100644 vendors/DateJS/.bower.json create mode 100644 vendors/DateJS/GruntFile.js create mode 100644 vendors/DateJS/LICENSE create mode 100644 vendors/DateJS/README.md create mode 100644 vendors/DateJS/bower.json create mode 100644 vendors/DateJS/build/date-af-ZA.js create mode 100644 vendors/DateJS/build/date-ar-AE.js create mode 100644 vendors/DateJS/build/date-ar-BH.js create mode 100644 vendors/DateJS/build/date-ar-DZ.js create mode 100644 vendors/DateJS/build/date-ar-EG.js create mode 100644 vendors/DateJS/build/date-ar-IQ.js create mode 100644 vendors/DateJS/build/date-ar-JO.js create mode 100644 vendors/DateJS/build/date-ar-KW.js create mode 100644 vendors/DateJS/build/date-ar-LB.js create mode 100644 vendors/DateJS/build/date-ar-LY.js create mode 100644 vendors/DateJS/build/date-ar-MA.js create mode 100644 vendors/DateJS/build/date-ar-OM.js create mode 100644 vendors/DateJS/build/date-ar-QA.js create mode 100644 vendors/DateJS/build/date-ar-SA.js create mode 100644 vendors/DateJS/build/date-ar-SY.js create mode 100644 vendors/DateJS/build/date-ar-TN.js create mode 100644 vendors/DateJS/build/date-ar-YE.js create mode 100644 vendors/DateJS/build/date-az-Cyrl-AZ.js create mode 100644 vendors/DateJS/build/date-az-Latn-AZ.js create mode 100644 vendors/DateJS/build/date-be-BY.js create mode 100644 vendors/DateJS/build/date-bg-BG.js create mode 100644 vendors/DateJS/build/date-bs-Latn-BA.js create mode 100644 vendors/DateJS/build/date-ca-ES.js create mode 100644 vendors/DateJS/build/date-cs-CZ.js create mode 100644 vendors/DateJS/build/date-cy-GB.js create mode 100644 vendors/DateJS/build/date-da-DK.js create mode 100644 vendors/DateJS/build/date-de-AT.js create mode 100644 vendors/DateJS/build/date-de-CH.js create mode 100644 vendors/DateJS/build/date-de-DE.js create mode 100644 vendors/DateJS/build/date-de-LI.js create mode 100644 vendors/DateJS/build/date-de-LU.js create mode 100644 vendors/DateJS/build/date-dv-MV.js create mode 100644 vendors/DateJS/build/date-el-GR.js create mode 100644 vendors/DateJS/build/date-en-029.js create mode 100644 vendors/DateJS/build/date-en-AU.js create mode 100644 vendors/DateJS/build/date-en-BZ.js create mode 100644 vendors/DateJS/build/date-en-CA.js create mode 100644 vendors/DateJS/build/date-en-GB.js create mode 100644 vendors/DateJS/build/date-en-IE.js create mode 100644 vendors/DateJS/build/date-en-JM.js create mode 100644 vendors/DateJS/build/date-en-NZ.js create mode 100644 vendors/DateJS/build/date-en-PH.js create mode 100644 vendors/DateJS/build/date-en-TT.js create mode 100644 vendors/DateJS/build/date-en-US.js create mode 100644 vendors/DateJS/build/date-en-ZA.js create mode 100644 vendors/DateJS/build/date-en-ZW.js create mode 100644 vendors/DateJS/build/date-es-AR.js create mode 100644 vendors/DateJS/build/date-es-BO.js create mode 100644 vendors/DateJS/build/date-es-CL.js create mode 100644 vendors/DateJS/build/date-es-CO.js create mode 100644 vendors/DateJS/build/date-es-CR.js create mode 100644 vendors/DateJS/build/date-es-DO.js create mode 100644 vendors/DateJS/build/date-es-EC.js create mode 100644 vendors/DateJS/build/date-es-ES.js create mode 100644 vendors/DateJS/build/date-es-GT.js create mode 100644 vendors/DateJS/build/date-es-HN.js create mode 100644 vendors/DateJS/build/date-es-MX.js create mode 100644 vendors/DateJS/build/date-es-NI.js create mode 100644 vendors/DateJS/build/date-es-PA.js create mode 100644 vendors/DateJS/build/date-es-PE.js create mode 100644 vendors/DateJS/build/date-es-PR.js create mode 100644 vendors/DateJS/build/date-es-PY.js create mode 100644 vendors/DateJS/build/date-es-SV.js create mode 100644 vendors/DateJS/build/date-es-UY.js create mode 100644 vendors/DateJS/build/date-es-VE.js create mode 100644 vendors/DateJS/build/date-et-EE.js create mode 100644 vendors/DateJS/build/date-eu-ES.js create mode 100644 vendors/DateJS/build/date-fa-IR.js create mode 100644 vendors/DateJS/build/date-fi-FI.js create mode 100644 vendors/DateJS/build/date-fo-FO.js create mode 100644 vendors/DateJS/build/date-fr-BE.js create mode 100644 vendors/DateJS/build/date-fr-CA.js create mode 100644 vendors/DateJS/build/date-fr-CH.js create mode 100644 vendors/DateJS/build/date-fr-FR.js create mode 100644 vendors/DateJS/build/date-fr-LU.js create mode 100644 vendors/DateJS/build/date-fr-MC.js create mode 100644 vendors/DateJS/build/date-gl-ES.js create mode 100644 vendors/DateJS/build/date-gu-IN.js create mode 100644 vendors/DateJS/build/date-he-IL.js create mode 100644 vendors/DateJS/build/date-hi-IN.js create mode 100644 vendors/DateJS/build/date-hr-BA.js create mode 100644 vendors/DateJS/build/date-hr-HR.js create mode 100644 vendors/DateJS/build/date-hu-HU.js create mode 100644 vendors/DateJS/build/date-hy-AM.js create mode 100644 vendors/DateJS/build/date-id-ID.js create mode 100644 vendors/DateJS/build/date-is-IS.js create mode 100644 vendors/DateJS/build/date-it-CH.js create mode 100644 vendors/DateJS/build/date-it-IT.js create mode 100644 vendors/DateJS/build/date-ja-JP.js create mode 100644 vendors/DateJS/build/date-ka-GE.js create mode 100644 vendors/DateJS/build/date-kk-KZ.js create mode 100644 vendors/DateJS/build/date-kn-IN.js create mode 100644 vendors/DateJS/build/date-ko-KR.js create mode 100644 vendors/DateJS/build/date-kok-IN.js create mode 100644 vendors/DateJS/build/date-ky-KG.js create mode 100644 vendors/DateJS/build/date-lt-LT.js create mode 100644 vendors/DateJS/build/date-lv-LV.js create mode 100644 vendors/DateJS/build/date-mi-NZ.js create mode 100644 vendors/DateJS/build/date-mk-MK.js create mode 100644 vendors/DateJS/build/date-mn-MN.js create mode 100644 vendors/DateJS/build/date-mr-IN.js create mode 100644 vendors/DateJS/build/date-ms-BN.js create mode 100644 vendors/DateJS/build/date-ms-MY.js create mode 100644 vendors/DateJS/build/date-mt-MT.js create mode 100644 vendors/DateJS/build/date-nb-NO.js create mode 100644 vendors/DateJS/build/date-nl-BE.js create mode 100644 vendors/DateJS/build/date-nl-NL.js create mode 100644 vendors/DateJS/build/date-nn-NO.js create mode 100644 vendors/DateJS/build/date-ns-ZA.js create mode 100644 vendors/DateJS/build/date-pa-IN.js create mode 100644 vendors/DateJS/build/date-pl-PL.js create mode 100644 vendors/DateJS/build/date-pt-BR.js create mode 100644 vendors/DateJS/build/date-pt-PT.js create mode 100644 vendors/DateJS/build/date-quz-BO.js create mode 100644 vendors/DateJS/build/date-quz-EC.js create mode 100644 vendors/DateJS/build/date-quz-PE.js create mode 100644 vendors/DateJS/build/date-ro-RO.js create mode 100644 vendors/DateJS/build/date-ru-RU.js create mode 100644 vendors/DateJS/build/date-sa-IN.js create mode 100644 vendors/DateJS/build/date-se-FI.js create mode 100644 vendors/DateJS/build/date-se-NO.js create mode 100644 vendors/DateJS/build/date-se-SE.js create mode 100644 vendors/DateJS/build/date-sk-SK.js create mode 100644 vendors/DateJS/build/date-sl-SI.js create mode 100644 vendors/DateJS/build/date-sma-NO.js create mode 100644 vendors/DateJS/build/date-sma-SE.js create mode 100644 vendors/DateJS/build/date-smj-NO.js create mode 100644 vendors/DateJS/build/date-smj-SE.js create mode 100644 vendors/DateJS/build/date-smn-FI.js create mode 100644 vendors/DateJS/build/date-sms-FI.js create mode 100644 vendors/DateJS/build/date-sq-AL.js create mode 100644 vendors/DateJS/build/date-sr-Cyrl-BA.js create mode 100644 vendors/DateJS/build/date-sr-Cyrl-CS.js create mode 100644 vendors/DateJS/build/date-sr-Latn-BA.js create mode 100644 vendors/DateJS/build/date-sr-Latn-CS.js create mode 100644 vendors/DateJS/build/date-sv-FI.js create mode 100644 vendors/DateJS/build/date-sv-SE.js create mode 100644 vendors/DateJS/build/date-sw-KE.js create mode 100644 vendors/DateJS/build/date-syr-SY.js create mode 100644 vendors/DateJS/build/date-ta-IN.js create mode 100644 vendors/DateJS/build/date-te-IN.js create mode 100644 vendors/DateJS/build/date-th-TH.js create mode 100644 vendors/DateJS/build/date-tn-ZA.js create mode 100644 vendors/DateJS/build/date-tr-TR.js create mode 100644 vendors/DateJS/build/date-tt-RU.js create mode 100644 vendors/DateJS/build/date-uk-UA.js create mode 100644 vendors/DateJS/build/date-ur-PK.js create mode 100644 vendors/DateJS/build/date-uz-Cyrl-UZ.js create mode 100644 vendors/DateJS/build/date-uz-Latn-UZ.js create mode 100644 vendors/DateJS/build/date-vi-VN.js create mode 100644 vendors/DateJS/build/date-xh-ZA.js create mode 100644 vendors/DateJS/build/date-zh-CN.js create mode 100644 vendors/DateJS/build/date-zh-HK.js create mode 100644 vendors/DateJS/build/date-zh-MO.js create mode 100644 vendors/DateJS/build/date-zh-SG.js create mode 100644 vendors/DateJS/build/date-zh-TW.js create mode 100644 vendors/DateJS/build/date-zu-ZA.js create mode 100644 vendors/DateJS/build/date.js create mode 100644 vendors/DateJS/build/i18n/af-ZA.js create mode 100644 vendors/DateJS/build/i18n/ar-AE.js create mode 100644 vendors/DateJS/build/i18n/ar-BH.js create mode 100644 vendors/DateJS/build/i18n/ar-DZ.js create mode 100644 vendors/DateJS/build/i18n/ar-EG.js create mode 100644 vendors/DateJS/build/i18n/ar-IQ.js create mode 100644 vendors/DateJS/build/i18n/ar-JO.js create mode 100644 vendors/DateJS/build/i18n/ar-KW.js create mode 100644 vendors/DateJS/build/i18n/ar-LB.js create mode 100644 vendors/DateJS/build/i18n/ar-LY.js create mode 100644 vendors/DateJS/build/i18n/ar-MA.js create mode 100644 vendors/DateJS/build/i18n/ar-OM.js create mode 100644 vendors/DateJS/build/i18n/ar-QA.js create mode 100644 vendors/DateJS/build/i18n/ar-SA.js create mode 100644 vendors/DateJS/build/i18n/ar-SY.js create mode 100644 vendors/DateJS/build/i18n/ar-TN.js create mode 100644 vendors/DateJS/build/i18n/ar-YE.js create mode 100644 vendors/DateJS/build/i18n/az-Cyrl-AZ.js create mode 100644 vendors/DateJS/build/i18n/az-Latn-AZ.js create mode 100644 vendors/DateJS/build/i18n/be-BY.js create mode 100644 vendors/DateJS/build/i18n/bg-BG.js create mode 100644 vendors/DateJS/build/i18n/bs-Latn-BA.js create mode 100644 vendors/DateJS/build/i18n/ca-ES.js create mode 100644 vendors/DateJS/build/i18n/cs-CZ.js create mode 100644 vendors/DateJS/build/i18n/cy-GB.js create mode 100644 vendors/DateJS/build/i18n/da-DK.js create mode 100644 vendors/DateJS/build/i18n/de-AT.js create mode 100644 vendors/DateJS/build/i18n/de-CH.js create mode 100644 vendors/DateJS/build/i18n/de-DE.js create mode 100644 vendors/DateJS/build/i18n/de-LI.js create mode 100644 vendors/DateJS/build/i18n/de-LU.js create mode 100644 vendors/DateJS/build/i18n/dv-MV.js create mode 100644 vendors/DateJS/build/i18n/el-GR.js create mode 100644 vendors/DateJS/build/i18n/en-029.js create mode 100644 vendors/DateJS/build/i18n/en-AU.js create mode 100644 vendors/DateJS/build/i18n/en-BZ.js create mode 100644 vendors/DateJS/build/i18n/en-CA.js create mode 100644 vendors/DateJS/build/i18n/en-GB.js create mode 100644 vendors/DateJS/build/i18n/en-IE.js create mode 100644 vendors/DateJS/build/i18n/en-JM.js create mode 100644 vendors/DateJS/build/i18n/en-NZ.js create mode 100644 vendors/DateJS/build/i18n/en-PH.js create mode 100644 vendors/DateJS/build/i18n/en-TT.js create mode 100644 vendors/DateJS/build/i18n/en-ZA.js create mode 100644 vendors/DateJS/build/i18n/en-ZW.js create mode 100644 vendors/DateJS/build/i18n/es-AR.js create mode 100644 vendors/DateJS/build/i18n/es-BO.js create mode 100644 vendors/DateJS/build/i18n/es-CL.js create mode 100644 vendors/DateJS/build/i18n/es-CO.js create mode 100644 vendors/DateJS/build/i18n/es-CR.js create mode 100644 vendors/DateJS/build/i18n/es-DO.js create mode 100644 vendors/DateJS/build/i18n/es-EC.js create mode 100644 vendors/DateJS/build/i18n/es-ES.js create mode 100644 vendors/DateJS/build/i18n/es-GT.js create mode 100644 vendors/DateJS/build/i18n/es-HN.js create mode 100644 vendors/DateJS/build/i18n/es-MX.js create mode 100644 vendors/DateJS/build/i18n/es-NI.js create mode 100644 vendors/DateJS/build/i18n/es-PA.js create mode 100644 vendors/DateJS/build/i18n/es-PE.js create mode 100644 vendors/DateJS/build/i18n/es-PR.js create mode 100644 vendors/DateJS/build/i18n/es-PY.js create mode 100644 vendors/DateJS/build/i18n/es-SV.js create mode 100644 vendors/DateJS/build/i18n/es-UY.js create mode 100644 vendors/DateJS/build/i18n/es-VE.js create mode 100644 vendors/DateJS/build/i18n/et-EE.js create mode 100644 vendors/DateJS/build/i18n/eu-ES.js create mode 100644 vendors/DateJS/build/i18n/fa-IR.js create mode 100644 vendors/DateJS/build/i18n/fi-FI.js create mode 100644 vendors/DateJS/build/i18n/fo-FO.js create mode 100644 vendors/DateJS/build/i18n/fr-BE.js create mode 100644 vendors/DateJS/build/i18n/fr-CA.js create mode 100644 vendors/DateJS/build/i18n/fr-CH.js create mode 100644 vendors/DateJS/build/i18n/fr-FR.js create mode 100644 vendors/DateJS/build/i18n/fr-LU.js create mode 100644 vendors/DateJS/build/i18n/fr-MC.js create mode 100644 vendors/DateJS/build/i18n/gl-ES.js create mode 100644 vendors/DateJS/build/i18n/gu-IN.js create mode 100644 vendors/DateJS/build/i18n/he-IL.js create mode 100644 vendors/DateJS/build/i18n/hi-IN.js create mode 100644 vendors/DateJS/build/i18n/hr-BA.js create mode 100644 vendors/DateJS/build/i18n/hr-HR.js create mode 100644 vendors/DateJS/build/i18n/hu-HU.js create mode 100644 vendors/DateJS/build/i18n/hy-AM.js create mode 100644 vendors/DateJS/build/i18n/id-ID.js create mode 100644 vendors/DateJS/build/i18n/is-IS.js create mode 100644 vendors/DateJS/build/i18n/it-CH.js create mode 100644 vendors/DateJS/build/i18n/it-IT.js create mode 100644 vendors/DateJS/build/i18n/ja-JP.js create mode 100644 vendors/DateJS/build/i18n/ka-GE.js create mode 100644 vendors/DateJS/build/i18n/kk-KZ.js create mode 100644 vendors/DateJS/build/i18n/kn-IN.js create mode 100644 vendors/DateJS/build/i18n/ko-KR.js create mode 100644 vendors/DateJS/build/i18n/kok-IN.js create mode 100644 vendors/DateJS/build/i18n/ky-KG.js create mode 100644 vendors/DateJS/build/i18n/lt-LT.js create mode 100644 vendors/DateJS/build/i18n/lv-LV.js create mode 100644 vendors/DateJS/build/i18n/mi-NZ.js create mode 100644 vendors/DateJS/build/i18n/mk-MK.js create mode 100644 vendors/DateJS/build/i18n/mn-MN.js create mode 100644 vendors/DateJS/build/i18n/mr-IN.js create mode 100644 vendors/DateJS/build/i18n/ms-BN.js create mode 100644 vendors/DateJS/build/i18n/ms-MY.js create mode 100644 vendors/DateJS/build/i18n/mt-MT.js create mode 100644 vendors/DateJS/build/i18n/nb-NO.js create mode 100644 vendors/DateJS/build/i18n/nl-BE.js create mode 100644 vendors/DateJS/build/i18n/nl-NL.js create mode 100644 vendors/DateJS/build/i18n/nn-NO.js create mode 100644 vendors/DateJS/build/i18n/ns-ZA.js create mode 100644 vendors/DateJS/build/i18n/pa-IN.js create mode 100644 vendors/DateJS/build/i18n/pl-PL.js create mode 100644 vendors/DateJS/build/i18n/pt-BR.js create mode 100644 vendors/DateJS/build/i18n/pt-PT.js create mode 100644 vendors/DateJS/build/i18n/quz-BO.js create mode 100644 vendors/DateJS/build/i18n/quz-EC.js create mode 100644 vendors/DateJS/build/i18n/quz-PE.js create mode 100644 vendors/DateJS/build/i18n/ro-RO.js create mode 100644 vendors/DateJS/build/i18n/ru-RU.js create mode 100644 vendors/DateJS/build/i18n/sa-IN.js create mode 100644 vendors/DateJS/build/i18n/se-FI.js create mode 100644 vendors/DateJS/build/i18n/se-NO.js create mode 100644 vendors/DateJS/build/i18n/se-SE.js create mode 100644 vendors/DateJS/build/i18n/sk-SK.js create mode 100644 vendors/DateJS/build/i18n/sl-SI.js create mode 100644 vendors/DateJS/build/i18n/sma-NO.js create mode 100644 vendors/DateJS/build/i18n/sma-SE.js create mode 100644 vendors/DateJS/build/i18n/smj-NO.js create mode 100644 vendors/DateJS/build/i18n/smj-SE.js create mode 100644 vendors/DateJS/build/i18n/smn-FI.js create mode 100644 vendors/DateJS/build/i18n/sms-FI.js create mode 100644 vendors/DateJS/build/i18n/sq-AL.js create mode 100644 vendors/DateJS/build/i18n/sr-Cyrl-BA.js create mode 100644 vendors/DateJS/build/i18n/sr-Cyrl-CS.js create mode 100644 vendors/DateJS/build/i18n/sr-Latn-BA.js create mode 100644 vendors/DateJS/build/i18n/sr-Latn-CS.js create mode 100644 vendors/DateJS/build/i18n/sv-FI.js create mode 100644 vendors/DateJS/build/i18n/sv-SE.js create mode 100644 vendors/DateJS/build/i18n/sw-KE.js create mode 100644 vendors/DateJS/build/i18n/syr-SY.js create mode 100644 vendors/DateJS/build/i18n/ta-IN.js create mode 100644 vendors/DateJS/build/i18n/te-IN.js create mode 100644 vendors/DateJS/build/i18n/th-TH.js create mode 100644 vendors/DateJS/build/i18n/tn-ZA.js create mode 100644 vendors/DateJS/build/i18n/tr-TR.js create mode 100644 vendors/DateJS/build/i18n/tt-RU.js create mode 100644 vendors/DateJS/build/i18n/uk-UA.js create mode 100644 vendors/DateJS/build/i18n/ur-PK.js create mode 100644 vendors/DateJS/build/i18n/uz-Cyrl-UZ.js create mode 100644 vendors/DateJS/build/i18n/uz-Latn-UZ.js create mode 100644 vendors/DateJS/build/i18n/vi-VN.js create mode 100644 vendors/DateJS/build/i18n/xh-ZA.js create mode 100644 vendors/DateJS/build/i18n/zh-CN.js create mode 100644 vendors/DateJS/build/i18n/zh-HK.js create mode 100644 vendors/DateJS/build/i18n/zh-MO.js create mode 100644 vendors/DateJS/build/i18n/zh-SG.js create mode 100644 vendors/DateJS/build/i18n/zh-TW.js create mode 100644 vendors/DateJS/build/i18n/zu-ZA.js create mode 100644 vendors/DateJS/build/production/date-af-ZA.min.js create mode 100644 vendors/DateJS/build/production/date-ar-AE.min.js create mode 100644 vendors/DateJS/build/production/date-ar-BH.min.js create mode 100644 vendors/DateJS/build/production/date-ar-DZ.min.js create mode 100644 vendors/DateJS/build/production/date-ar-EG.min.js create mode 100644 vendors/DateJS/build/production/date-ar-IQ.min.js create mode 100644 vendors/DateJS/build/production/date-ar-JO.min.js create mode 100644 vendors/DateJS/build/production/date-ar-KW.min.js create mode 100644 vendors/DateJS/build/production/date-ar-LB.min.js create mode 100644 vendors/DateJS/build/production/date-ar-LY.min.js create mode 100644 vendors/DateJS/build/production/date-ar-MA.min.js create mode 100644 vendors/DateJS/build/production/date-ar-OM.min.js create mode 100644 vendors/DateJS/build/production/date-ar-QA.min.js create mode 100644 vendors/DateJS/build/production/date-ar-SA.min.js create mode 100644 vendors/DateJS/build/production/date-ar-SY.min.js create mode 100644 vendors/DateJS/build/production/date-ar-TN.min.js create mode 100644 vendors/DateJS/build/production/date-ar-YE.min.js create mode 100644 vendors/DateJS/build/production/date-az-Cyrl-AZ.min.js create mode 100644 vendors/DateJS/build/production/date-az-Latn-AZ.min.js create mode 100644 vendors/DateJS/build/production/date-be-BY.min.js create mode 100644 vendors/DateJS/build/production/date-bg-BG.min.js create mode 100644 vendors/DateJS/build/production/date-bs-Latn-BA.min.js create mode 100644 vendors/DateJS/build/production/date-ca-ES.min.js create mode 100644 vendors/DateJS/build/production/date-cs-CZ.min.js create mode 100644 vendors/DateJS/build/production/date-cy-GB.min.js create mode 100644 vendors/DateJS/build/production/date-da-DK.min.js create mode 100644 vendors/DateJS/build/production/date-de-AT.min.js create mode 100644 vendors/DateJS/build/production/date-de-CH.min.js create mode 100644 vendors/DateJS/build/production/date-de-DE.min.js create mode 100644 vendors/DateJS/build/production/date-de-LI.min.js create mode 100644 vendors/DateJS/build/production/date-de-LU.min.js create mode 100644 vendors/DateJS/build/production/date-dv-MV.min.js create mode 100644 vendors/DateJS/build/production/date-el-GR.min.js create mode 100644 vendors/DateJS/build/production/date-en-029.min.js create mode 100644 vendors/DateJS/build/production/date-en-AU.min.js create mode 100644 vendors/DateJS/build/production/date-en-BZ.min.js create mode 100644 vendors/DateJS/build/production/date-en-CA.min.js create mode 100644 vendors/DateJS/build/production/date-en-GB.min.js create mode 100644 vendors/DateJS/build/production/date-en-IE.min.js create mode 100644 vendors/DateJS/build/production/date-en-JM.min.js create mode 100644 vendors/DateJS/build/production/date-en-NZ.min.js create mode 100644 vendors/DateJS/build/production/date-en-PH.min.js create mode 100644 vendors/DateJS/build/production/date-en-TT.min.js create mode 100644 vendors/DateJS/build/production/date-en-US.min.js create mode 100644 vendors/DateJS/build/production/date-en-ZA.min.js create mode 100644 vendors/DateJS/build/production/date-en-ZW.min.js create mode 100644 vendors/DateJS/build/production/date-es-AR.min.js create mode 100644 vendors/DateJS/build/production/date-es-BO.min.js create mode 100644 vendors/DateJS/build/production/date-es-CL.min.js create mode 100644 vendors/DateJS/build/production/date-es-CO.min.js create mode 100644 vendors/DateJS/build/production/date-es-CR.min.js create mode 100644 vendors/DateJS/build/production/date-es-DO.min.js create mode 100644 vendors/DateJS/build/production/date-es-EC.min.js create mode 100644 vendors/DateJS/build/production/date-es-ES.min.js create mode 100644 vendors/DateJS/build/production/date-es-GT.min.js create mode 100644 vendors/DateJS/build/production/date-es-HN.min.js create mode 100644 vendors/DateJS/build/production/date-es-MX.min.js create mode 100644 vendors/DateJS/build/production/date-es-NI.min.js create mode 100644 vendors/DateJS/build/production/date-es-PA.min.js create mode 100644 vendors/DateJS/build/production/date-es-PE.min.js create mode 100644 vendors/DateJS/build/production/date-es-PR.min.js create mode 100644 vendors/DateJS/build/production/date-es-PY.min.js create mode 100644 vendors/DateJS/build/production/date-es-SV.min.js create mode 100644 vendors/DateJS/build/production/date-es-UY.min.js create mode 100644 vendors/DateJS/build/production/date-es-VE.min.js create mode 100644 vendors/DateJS/build/production/date-et-EE.min.js create mode 100644 vendors/DateJS/build/production/date-eu-ES.min.js create mode 100644 vendors/DateJS/build/production/date-fa-IR.min.js create mode 100644 vendors/DateJS/build/production/date-fi-FI.min.js create mode 100644 vendors/DateJS/build/production/date-fo-FO.min.js create mode 100644 vendors/DateJS/build/production/date-fr-BE.min.js create mode 100644 vendors/DateJS/build/production/date-fr-CA.min.js create mode 100644 vendors/DateJS/build/production/date-fr-CH.min.js create mode 100644 vendors/DateJS/build/production/date-fr-FR.min.js create mode 100644 vendors/DateJS/build/production/date-fr-LU.min.js create mode 100644 vendors/DateJS/build/production/date-fr-MC.min.js create mode 100644 vendors/DateJS/build/production/date-gl-ES.min.js create mode 100644 vendors/DateJS/build/production/date-gu-IN.min.js create mode 100644 vendors/DateJS/build/production/date-he-IL.min.js create mode 100644 vendors/DateJS/build/production/date-hi-IN.min.js create mode 100644 vendors/DateJS/build/production/date-hr-BA.min.js create mode 100644 vendors/DateJS/build/production/date-hr-HR.min.js create mode 100644 vendors/DateJS/build/production/date-hu-HU.min.js create mode 100644 vendors/DateJS/build/production/date-hy-AM.min.js create mode 100644 vendors/DateJS/build/production/date-id-ID.min.js create mode 100644 vendors/DateJS/build/production/date-is-IS.min.js create mode 100644 vendors/DateJS/build/production/date-it-CH.min.js create mode 100644 vendors/DateJS/build/production/date-it-IT.min.js create mode 100644 vendors/DateJS/build/production/date-ja-JP.min.js create mode 100644 vendors/DateJS/build/production/date-ka-GE.min.js create mode 100644 vendors/DateJS/build/production/date-kk-KZ.min.js create mode 100644 vendors/DateJS/build/production/date-kn-IN.min.js create mode 100644 vendors/DateJS/build/production/date-ko-KR.min.js create mode 100644 vendors/DateJS/build/production/date-kok-IN.min.js create mode 100644 vendors/DateJS/build/production/date-ky-KG.min.js create mode 100644 vendors/DateJS/build/production/date-lt-LT.min.js create mode 100644 vendors/DateJS/build/production/date-lv-LV.min.js create mode 100644 vendors/DateJS/build/production/date-mi-NZ.min.js create mode 100644 vendors/DateJS/build/production/date-mk-MK.min.js create mode 100644 vendors/DateJS/build/production/date-mn-MN.min.js create mode 100644 vendors/DateJS/build/production/date-mr-IN.min.js create mode 100644 vendors/DateJS/build/production/date-ms-BN.min.js create mode 100644 vendors/DateJS/build/production/date-ms-MY.min.js create mode 100644 vendors/DateJS/build/production/date-mt-MT.min.js create mode 100644 vendors/DateJS/build/production/date-nb-NO.min.js create mode 100644 vendors/DateJS/build/production/date-nl-BE.min.js create mode 100644 vendors/DateJS/build/production/date-nl-NL.min.js create mode 100644 vendors/DateJS/build/production/date-nn-NO.min.js create mode 100644 vendors/DateJS/build/production/date-ns-ZA.min.js create mode 100644 vendors/DateJS/build/production/date-pa-IN.min.js create mode 100644 vendors/DateJS/build/production/date-pl-PL.min.js create mode 100644 vendors/DateJS/build/production/date-pt-BR.min.js create mode 100644 vendors/DateJS/build/production/date-pt-PT.min.js create mode 100644 vendors/DateJS/build/production/date-quz-BO.min.js create mode 100644 vendors/DateJS/build/production/date-quz-EC.min.js create mode 100644 vendors/DateJS/build/production/date-quz-PE.min.js create mode 100644 vendors/DateJS/build/production/date-ro-RO.min.js create mode 100644 vendors/DateJS/build/production/date-ru-RU.min.js create mode 100644 vendors/DateJS/build/production/date-sa-IN.min.js create mode 100644 vendors/DateJS/build/production/date-se-FI.min.js create mode 100644 vendors/DateJS/build/production/date-se-NO.min.js create mode 100644 vendors/DateJS/build/production/date-se-SE.min.js create mode 100644 vendors/DateJS/build/production/date-sk-SK.min.js create mode 100644 vendors/DateJS/build/production/date-sl-SI.min.js create mode 100644 vendors/DateJS/build/production/date-sma-NO.min.js create mode 100644 vendors/DateJS/build/production/date-sma-SE.min.js create mode 100644 vendors/DateJS/build/production/date-smj-NO.min.js create mode 100644 vendors/DateJS/build/production/date-smj-SE.min.js create mode 100644 vendors/DateJS/build/production/date-smn-FI.min.js create mode 100644 vendors/DateJS/build/production/date-sms-FI.min.js create mode 100644 vendors/DateJS/build/production/date-sq-AL.min.js create mode 100644 vendors/DateJS/build/production/date-sr-Cyrl-BA.min.js create mode 100644 vendors/DateJS/build/production/date-sr-Cyrl-CS.min.js create mode 100644 vendors/DateJS/build/production/date-sr-Latn-BA.min.js create mode 100644 vendors/DateJS/build/production/date-sr-Latn-CS.min.js create mode 100644 vendors/DateJS/build/production/date-sv-FI.min.js create mode 100644 vendors/DateJS/build/production/date-sv-SE.min.js create mode 100644 vendors/DateJS/build/production/date-sw-KE.min.js create mode 100644 vendors/DateJS/build/production/date-syr-SY.min.js create mode 100644 vendors/DateJS/build/production/date-ta-IN.min.js create mode 100644 vendors/DateJS/build/production/date-te-IN.min.js create mode 100644 vendors/DateJS/build/production/date-th-TH.min.js create mode 100644 vendors/DateJS/build/production/date-tn-ZA.min.js create mode 100644 vendors/DateJS/build/production/date-tr-TR.min.js create mode 100644 vendors/DateJS/build/production/date-tt-RU.min.js create mode 100644 vendors/DateJS/build/production/date-uk-UA.min.js create mode 100644 vendors/DateJS/build/production/date-ur-PK.min.js create mode 100644 vendors/DateJS/build/production/date-uz-Cyrl-UZ.min.js create mode 100644 vendors/DateJS/build/production/date-uz-Latn-UZ.min.js create mode 100644 vendors/DateJS/build/production/date-vi-VN.min.js create mode 100644 vendors/DateJS/build/production/date-xh-ZA.min.js create mode 100644 vendors/DateJS/build/production/date-zh-CN.min.js create mode 100644 vendors/DateJS/build/production/date-zh-HK.min.js create mode 100644 vendors/DateJS/build/production/date-zh-MO.min.js create mode 100644 vendors/DateJS/build/production/date-zh-SG.min.js create mode 100644 vendors/DateJS/build/production/date-zh-TW.min.js create mode 100644 vendors/DateJS/build/production/date-zu-ZA.min.js create mode 100644 vendors/DateJS/build/production/date.min.js create mode 100644 vendors/DateJS/build/production/i18n/af-ZA.js create mode 100644 vendors/DateJS/build/production/i18n/ar-AE.js create mode 100644 vendors/DateJS/build/production/i18n/ar-BH.js create mode 100644 vendors/DateJS/build/production/i18n/ar-DZ.js create mode 100644 vendors/DateJS/build/production/i18n/ar-EG.js create mode 100644 vendors/DateJS/build/production/i18n/ar-IQ.js create mode 100644 vendors/DateJS/build/production/i18n/ar-JO.js create mode 100644 vendors/DateJS/build/production/i18n/ar-KW.js create mode 100644 vendors/DateJS/build/production/i18n/ar-LB.js create mode 100644 vendors/DateJS/build/production/i18n/ar-LY.js create mode 100644 vendors/DateJS/build/production/i18n/ar-MA.js create mode 100644 vendors/DateJS/build/production/i18n/ar-OM.js create mode 100644 vendors/DateJS/build/production/i18n/ar-QA.js create mode 100644 vendors/DateJS/build/production/i18n/ar-SA.js create mode 100644 vendors/DateJS/build/production/i18n/ar-SY.js create mode 100644 vendors/DateJS/build/production/i18n/ar-TN.js create mode 100644 vendors/DateJS/build/production/i18n/ar-YE.js create mode 100644 vendors/DateJS/build/production/i18n/az-Cyrl-AZ.js create mode 100644 vendors/DateJS/build/production/i18n/az-Latn-AZ.js create mode 100644 vendors/DateJS/build/production/i18n/be-BY.js create mode 100644 vendors/DateJS/build/production/i18n/bg-BG.js create mode 100644 vendors/DateJS/build/production/i18n/bs-Latn-BA.js create mode 100644 vendors/DateJS/build/production/i18n/ca-ES.js create mode 100644 vendors/DateJS/build/production/i18n/cs-CZ.js create mode 100644 vendors/DateJS/build/production/i18n/cy-GB.js create mode 100644 vendors/DateJS/build/production/i18n/da-DK.js create mode 100644 vendors/DateJS/build/production/i18n/de-AT.js create mode 100644 vendors/DateJS/build/production/i18n/de-CH.js create mode 100644 vendors/DateJS/build/production/i18n/de-DE.js create mode 100644 vendors/DateJS/build/production/i18n/de-LI.js create mode 100644 vendors/DateJS/build/production/i18n/de-LU.js create mode 100644 vendors/DateJS/build/production/i18n/dv-MV.js create mode 100644 vendors/DateJS/build/production/i18n/el-GR.js create mode 100644 vendors/DateJS/build/production/i18n/en-029.js create mode 100644 vendors/DateJS/build/production/i18n/en-AU.js create mode 100644 vendors/DateJS/build/production/i18n/en-BZ.js create mode 100644 vendors/DateJS/build/production/i18n/en-CA.js create mode 100644 vendors/DateJS/build/production/i18n/en-GB.js create mode 100644 vendors/DateJS/build/production/i18n/en-IE.js create mode 100644 vendors/DateJS/build/production/i18n/en-JM.js create mode 100644 vendors/DateJS/build/production/i18n/en-NZ.js create mode 100644 vendors/DateJS/build/production/i18n/en-PH.js create mode 100644 vendors/DateJS/build/production/i18n/en-TT.js create mode 100644 vendors/DateJS/build/production/i18n/en-ZA.js create mode 100644 vendors/DateJS/build/production/i18n/en-ZW.js create mode 100644 vendors/DateJS/build/production/i18n/es-AR.js create mode 100644 vendors/DateJS/build/production/i18n/es-BO.js create mode 100644 vendors/DateJS/build/production/i18n/es-CL.js create mode 100644 vendors/DateJS/build/production/i18n/es-CO.js create mode 100644 vendors/DateJS/build/production/i18n/es-CR.js create mode 100644 vendors/DateJS/build/production/i18n/es-DO.js create mode 100644 vendors/DateJS/build/production/i18n/es-EC.js create mode 100644 vendors/DateJS/build/production/i18n/es-ES.js create mode 100644 vendors/DateJS/build/production/i18n/es-GT.js create mode 100644 vendors/DateJS/build/production/i18n/es-HN.js create mode 100644 vendors/DateJS/build/production/i18n/es-MX.js create mode 100644 vendors/DateJS/build/production/i18n/es-NI.js create mode 100644 vendors/DateJS/build/production/i18n/es-PA.js create mode 100644 vendors/DateJS/build/production/i18n/es-PE.js create mode 100644 vendors/DateJS/build/production/i18n/es-PR.js create mode 100644 vendors/DateJS/build/production/i18n/es-PY.js create mode 100644 vendors/DateJS/build/production/i18n/es-SV.js create mode 100644 vendors/DateJS/build/production/i18n/es-UY.js create mode 100644 vendors/DateJS/build/production/i18n/es-VE.js create mode 100644 vendors/DateJS/build/production/i18n/et-EE.js create mode 100644 vendors/DateJS/build/production/i18n/eu-ES.js create mode 100644 vendors/DateJS/build/production/i18n/fa-IR.js create mode 100644 vendors/DateJS/build/production/i18n/fi-FI.js create mode 100644 vendors/DateJS/build/production/i18n/fo-FO.js create mode 100644 vendors/DateJS/build/production/i18n/fr-BE.js create mode 100644 vendors/DateJS/build/production/i18n/fr-CA.js create mode 100644 vendors/DateJS/build/production/i18n/fr-CH.js create mode 100644 vendors/DateJS/build/production/i18n/fr-FR.js create mode 100644 vendors/DateJS/build/production/i18n/fr-LU.js create mode 100644 vendors/DateJS/build/production/i18n/fr-MC.js create mode 100644 vendors/DateJS/build/production/i18n/gl-ES.js create mode 100644 vendors/DateJS/build/production/i18n/gu-IN.js create mode 100644 vendors/DateJS/build/production/i18n/he-IL.js create mode 100644 vendors/DateJS/build/production/i18n/hi-IN.js create mode 100644 vendors/DateJS/build/production/i18n/hr-BA.js create mode 100644 vendors/DateJS/build/production/i18n/hr-HR.js create mode 100644 vendors/DateJS/build/production/i18n/hu-HU.js create mode 100644 vendors/DateJS/build/production/i18n/hy-AM.js create mode 100644 vendors/DateJS/build/production/i18n/id-ID.js create mode 100644 vendors/DateJS/build/production/i18n/is-IS.js create mode 100644 vendors/DateJS/build/production/i18n/it-CH.js create mode 100644 vendors/DateJS/build/production/i18n/it-IT.js create mode 100644 vendors/DateJS/build/production/i18n/ja-JP.js create mode 100644 vendors/DateJS/build/production/i18n/ka-GE.js create mode 100644 vendors/DateJS/build/production/i18n/kk-KZ.js create mode 100644 vendors/DateJS/build/production/i18n/kn-IN.js create mode 100644 vendors/DateJS/build/production/i18n/ko-KR.js create mode 100644 vendors/DateJS/build/production/i18n/kok-IN.js create mode 100644 vendors/DateJS/build/production/i18n/ky-KG.js create mode 100644 vendors/DateJS/build/production/i18n/lt-LT.js create mode 100644 vendors/DateJS/build/production/i18n/lv-LV.js create mode 100644 vendors/DateJS/build/production/i18n/mi-NZ.js create mode 100644 vendors/DateJS/build/production/i18n/mk-MK.js create mode 100644 vendors/DateJS/build/production/i18n/mn-MN.js create mode 100644 vendors/DateJS/build/production/i18n/mr-IN.js create mode 100644 vendors/DateJS/build/production/i18n/ms-BN.js create mode 100644 vendors/DateJS/build/production/i18n/ms-MY.js create mode 100644 vendors/DateJS/build/production/i18n/mt-MT.js create mode 100644 vendors/DateJS/build/production/i18n/nb-NO.js create mode 100644 vendors/DateJS/build/production/i18n/nl-BE.js create mode 100644 vendors/DateJS/build/production/i18n/nl-NL.js create mode 100644 vendors/DateJS/build/production/i18n/nn-NO.js create mode 100644 vendors/DateJS/build/production/i18n/ns-ZA.js create mode 100644 vendors/DateJS/build/production/i18n/pa-IN.js create mode 100644 vendors/DateJS/build/production/i18n/pl-PL.js create mode 100644 vendors/DateJS/build/production/i18n/pt-BR.js create mode 100644 vendors/DateJS/build/production/i18n/pt-PT.js create mode 100644 vendors/DateJS/build/production/i18n/quz-BO.js create mode 100644 vendors/DateJS/build/production/i18n/quz-EC.js create mode 100644 vendors/DateJS/build/production/i18n/quz-PE.js create mode 100644 vendors/DateJS/build/production/i18n/ro-RO.js create mode 100644 vendors/DateJS/build/production/i18n/ru-RU.js create mode 100644 vendors/DateJS/build/production/i18n/sa-IN.js create mode 100644 vendors/DateJS/build/production/i18n/se-FI.js create mode 100644 vendors/DateJS/build/production/i18n/se-NO.js create mode 100644 vendors/DateJS/build/production/i18n/se-SE.js create mode 100644 vendors/DateJS/build/production/i18n/sk-SK.js create mode 100644 vendors/DateJS/build/production/i18n/sl-SI.js create mode 100644 vendors/DateJS/build/production/i18n/sma-NO.js create mode 100644 vendors/DateJS/build/production/i18n/sma-SE.js create mode 100644 vendors/DateJS/build/production/i18n/smj-NO.js create mode 100644 vendors/DateJS/build/production/i18n/smj-SE.js create mode 100644 vendors/DateJS/build/production/i18n/smn-FI.js create mode 100644 vendors/DateJS/build/production/i18n/sms-FI.js create mode 100644 vendors/DateJS/build/production/i18n/sq-AL.js create mode 100644 vendors/DateJS/build/production/i18n/sr-Cyrl-BA.js create mode 100644 vendors/DateJS/build/production/i18n/sr-Cyrl-CS.js create mode 100644 vendors/DateJS/build/production/i18n/sr-Latn-BA.js create mode 100644 vendors/DateJS/build/production/i18n/sr-Latn-CS.js create mode 100644 vendors/DateJS/build/production/i18n/sv-FI.js create mode 100644 vendors/DateJS/build/production/i18n/sv-SE.js create mode 100644 vendors/DateJS/build/production/i18n/sw-KE.js create mode 100644 vendors/DateJS/build/production/i18n/syr-SY.js create mode 100644 vendors/DateJS/build/production/i18n/ta-IN.js create mode 100644 vendors/DateJS/build/production/i18n/te-IN.js create mode 100644 vendors/DateJS/build/production/i18n/th-TH.js create mode 100644 vendors/DateJS/build/production/i18n/tn-ZA.js create mode 100644 vendors/DateJS/build/production/i18n/tr-TR.js create mode 100644 vendors/DateJS/build/production/i18n/tt-RU.js create mode 100644 vendors/DateJS/build/production/i18n/uk-UA.js create mode 100644 vendors/DateJS/build/production/i18n/ur-PK.js create mode 100644 vendors/DateJS/build/production/i18n/uz-Cyrl-UZ.js create mode 100644 vendors/DateJS/build/production/i18n/uz-Latn-UZ.js create mode 100644 vendors/DateJS/build/production/i18n/vi-VN.js create mode 100644 vendors/DateJS/build/production/i18n/xh-ZA.js create mode 100644 vendors/DateJS/build/production/i18n/zh-CN.js create mode 100644 vendors/DateJS/build/production/i18n/zh-HK.js create mode 100644 vendors/DateJS/build/production/i18n/zh-MO.js create mode 100644 vendors/DateJS/build/production/i18n/zh-SG.js create mode 100644 vendors/DateJS/build/production/i18n/zh-TW.js create mode 100644 vendors/DateJS/build/production/i18n/zu-ZA.js create mode 100644 vendors/DateJS/index.js create mode 100644 vendors/DateJS/package.json create mode 100644 vendors/DateJS/reports/coverage.json create mode 100644 vendors/DateJS/reports/lcov-report/core/core-prototypes.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/core.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/extras.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/format_parser.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/i18n.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/index.html create mode 100644 vendors/DateJS/reports/lcov-report/core/parser.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/parsing_grammar.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/parsing_operators.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/parsing_translator.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/sugarpak.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/time_period.js.html create mode 100644 vendors/DateJS/reports/lcov-report/core/time_span.js.html create mode 100644 vendors/DateJS/reports/lcov-report/index.html create mode 100644 vendors/DateJS/reports/lcov-report/prettify.css create mode 100644 vendors/DateJS/reports/lcov-report/prettify.js create mode 100644 vendors/DateJS/reports/lcov.info create mode 100644 vendors/DateJS/src/core/core-prototypes.js create mode 100644 vendors/DateJS/src/core/core.js create mode 100644 vendors/DateJS/src/core/extras.js create mode 100644 vendors/DateJS/src/core/format_parser.js create mode 100644 vendors/DateJS/src/core/i18n.js create mode 100644 vendors/DateJS/src/core/parser.js create mode 100644 vendors/DateJS/src/core/parsing_grammar.js create mode 100644 vendors/DateJS/src/core/parsing_operators.js create mode 100644 vendors/DateJS/src/core/parsing_translator.js create mode 100644 vendors/DateJS/src/core/sugarpak.js create mode 100644 vendors/DateJS/src/core/time_period.js create mode 100644 vendors/DateJS/src/core/time_span.js create mode 100644 vendors/DateJS/src/i18n-template.js create mode 100644 vendors/DateJS/src/i18n/af-ZA.js create mode 100644 vendors/DateJS/src/i18n/ar-AE.js create mode 100644 vendors/DateJS/src/i18n/ar-BH.js create mode 100644 vendors/DateJS/src/i18n/ar-DZ.js create mode 100644 vendors/DateJS/src/i18n/ar-EG.js create mode 100644 vendors/DateJS/src/i18n/ar-IQ.js create mode 100644 vendors/DateJS/src/i18n/ar-JO.js create mode 100644 vendors/DateJS/src/i18n/ar-KW.js create mode 100644 vendors/DateJS/src/i18n/ar-LB.js create mode 100644 vendors/DateJS/src/i18n/ar-LY.js create mode 100644 vendors/DateJS/src/i18n/ar-MA.js create mode 100644 vendors/DateJS/src/i18n/ar-OM.js create mode 100644 vendors/DateJS/src/i18n/ar-QA.js create mode 100644 vendors/DateJS/src/i18n/ar-SA.js create mode 100644 vendors/DateJS/src/i18n/ar-SY.js create mode 100644 vendors/DateJS/src/i18n/ar-TN.js create mode 100644 vendors/DateJS/src/i18n/ar-YE.js create mode 100644 vendors/DateJS/src/i18n/az-Cyrl-AZ.js create mode 100644 vendors/DateJS/src/i18n/az-Latn-AZ.js create mode 100644 vendors/DateJS/src/i18n/be-BY.js create mode 100644 vendors/DateJS/src/i18n/bg-BG.js create mode 100644 vendors/DateJS/src/i18n/bs-Latn-BA.js create mode 100644 vendors/DateJS/src/i18n/ca-ES.js create mode 100644 vendors/DateJS/src/i18n/cs-CZ.js create mode 100644 vendors/DateJS/src/i18n/cy-GB.js create mode 100644 vendors/DateJS/src/i18n/da-DK.js create mode 100644 vendors/DateJS/src/i18n/de-AT.js create mode 100644 vendors/DateJS/src/i18n/de-CH.js create mode 100644 vendors/DateJS/src/i18n/de-DE.js create mode 100644 vendors/DateJS/src/i18n/de-LI.js create mode 100644 vendors/DateJS/src/i18n/de-LU.js create mode 100644 vendors/DateJS/src/i18n/dv-MV.js create mode 100644 vendors/DateJS/src/i18n/el-GR.js create mode 100644 vendors/DateJS/src/i18n/en-029.js create mode 100644 vendors/DateJS/src/i18n/en-AU.js create mode 100644 vendors/DateJS/src/i18n/en-BZ.js create mode 100644 vendors/DateJS/src/i18n/en-CA.js create mode 100644 vendors/DateJS/src/i18n/en-GB.js create mode 100644 vendors/DateJS/src/i18n/en-IE.js create mode 100644 vendors/DateJS/src/i18n/en-JM.js create mode 100644 vendors/DateJS/src/i18n/en-NZ.js create mode 100644 vendors/DateJS/src/i18n/en-PH.js create mode 100644 vendors/DateJS/src/i18n/en-TT.js create mode 100644 vendors/DateJS/src/i18n/en-ZA.js create mode 100644 vendors/DateJS/src/i18n/en-ZW.js create mode 100644 vendors/DateJS/src/i18n/es-AR.js create mode 100644 vendors/DateJS/src/i18n/es-BO.js create mode 100644 vendors/DateJS/src/i18n/es-CL.js create mode 100644 vendors/DateJS/src/i18n/es-CO.js create mode 100644 vendors/DateJS/src/i18n/es-CR.js create mode 100644 vendors/DateJS/src/i18n/es-DO.js create mode 100644 vendors/DateJS/src/i18n/es-EC.js create mode 100644 vendors/DateJS/src/i18n/es-ES.js create mode 100644 vendors/DateJS/src/i18n/es-GT.js create mode 100644 vendors/DateJS/src/i18n/es-HN.js create mode 100644 vendors/DateJS/src/i18n/es-MX.js create mode 100644 vendors/DateJS/src/i18n/es-NI.js create mode 100644 vendors/DateJS/src/i18n/es-PA.js create mode 100644 vendors/DateJS/src/i18n/es-PE.js create mode 100644 vendors/DateJS/src/i18n/es-PR.js create mode 100644 vendors/DateJS/src/i18n/es-PY.js create mode 100644 vendors/DateJS/src/i18n/es-SV.js create mode 100644 vendors/DateJS/src/i18n/es-UY.js create mode 100644 vendors/DateJS/src/i18n/es-VE.js create mode 100644 vendors/DateJS/src/i18n/et-EE.js create mode 100644 vendors/DateJS/src/i18n/eu-ES.js create mode 100644 vendors/DateJS/src/i18n/fa-IR.js create mode 100644 vendors/DateJS/src/i18n/fi-FI.js create mode 100644 vendors/DateJS/src/i18n/fo-FO.js create mode 100644 vendors/DateJS/src/i18n/fr-BE.js create mode 100644 vendors/DateJS/src/i18n/fr-CA.js create mode 100644 vendors/DateJS/src/i18n/fr-CH.js create mode 100644 vendors/DateJS/src/i18n/fr-FR.js create mode 100644 vendors/DateJS/src/i18n/fr-LU.js create mode 100644 vendors/DateJS/src/i18n/fr-MC.js create mode 100644 vendors/DateJS/src/i18n/gl-ES.js create mode 100644 vendors/DateJS/src/i18n/gu-IN.js create mode 100644 vendors/DateJS/src/i18n/he-IL.js create mode 100644 vendors/DateJS/src/i18n/hi-IN.js create mode 100644 vendors/DateJS/src/i18n/hr-BA.js create mode 100644 vendors/DateJS/src/i18n/hr-HR.js create mode 100644 vendors/DateJS/src/i18n/hu-HU.js create mode 100644 vendors/DateJS/src/i18n/hy-AM.js create mode 100644 vendors/DateJS/src/i18n/id-ID.js create mode 100644 vendors/DateJS/src/i18n/is-IS.js create mode 100644 vendors/DateJS/src/i18n/it-CH.js create mode 100644 vendors/DateJS/src/i18n/it-IT.js create mode 100644 vendors/DateJS/src/i18n/ja-JP.js create mode 100644 vendors/DateJS/src/i18n/ka-GE.js create mode 100644 vendors/DateJS/src/i18n/kk-KZ.js create mode 100644 vendors/DateJS/src/i18n/kn-IN.js create mode 100644 vendors/DateJS/src/i18n/ko-KR.js create mode 100644 vendors/DateJS/src/i18n/kok-IN.js create mode 100644 vendors/DateJS/src/i18n/ky-KG.js create mode 100644 vendors/DateJS/src/i18n/lt-LT.js create mode 100644 vendors/DateJS/src/i18n/lv-LV.js create mode 100644 vendors/DateJS/src/i18n/mi-NZ.js create mode 100644 vendors/DateJS/src/i18n/mk-MK.js create mode 100644 vendors/DateJS/src/i18n/mn-MN.js create mode 100644 vendors/DateJS/src/i18n/mr-IN.js create mode 100644 vendors/DateJS/src/i18n/ms-BN.js create mode 100644 vendors/DateJS/src/i18n/ms-MY.js create mode 100644 vendors/DateJS/src/i18n/mt-MT.js create mode 100644 vendors/DateJS/src/i18n/nb-NO.js create mode 100644 vendors/DateJS/src/i18n/nl-BE.js create mode 100644 vendors/DateJS/src/i18n/nl-NL.js create mode 100644 vendors/DateJS/src/i18n/nn-NO.js create mode 100644 vendors/DateJS/src/i18n/ns-ZA.js create mode 100644 vendors/DateJS/src/i18n/pa-IN.js create mode 100644 vendors/DateJS/src/i18n/pl-PL.js create mode 100644 vendors/DateJS/src/i18n/pt-BR.js create mode 100644 vendors/DateJS/src/i18n/pt-PT.js create mode 100644 vendors/DateJS/src/i18n/quz-BO.js create mode 100644 vendors/DateJS/src/i18n/quz-EC.js create mode 100644 vendors/DateJS/src/i18n/quz-PE.js create mode 100644 vendors/DateJS/src/i18n/ro-RO.js create mode 100644 vendors/DateJS/src/i18n/ru-RU.js create mode 100644 vendors/DateJS/src/i18n/sa-IN.js create mode 100644 vendors/DateJS/src/i18n/se-FI.js create mode 100644 vendors/DateJS/src/i18n/se-NO.js create mode 100644 vendors/DateJS/src/i18n/se-SE.js create mode 100644 vendors/DateJS/src/i18n/sk-SK.js create mode 100644 vendors/DateJS/src/i18n/sl-SI.js create mode 100644 vendors/DateJS/src/i18n/sma-NO.js create mode 100644 vendors/DateJS/src/i18n/sma-SE.js create mode 100644 vendors/DateJS/src/i18n/smj-NO.js create mode 100644 vendors/DateJS/src/i18n/smj-SE.js create mode 100644 vendors/DateJS/src/i18n/smn-FI.js create mode 100644 vendors/DateJS/src/i18n/sms-FI.js create mode 100644 vendors/DateJS/src/i18n/sq-AL.js create mode 100644 vendors/DateJS/src/i18n/sr-Cyrl-BA.js create mode 100644 vendors/DateJS/src/i18n/sr-Cyrl-CS.js create mode 100644 vendors/DateJS/src/i18n/sr-Latn-BA.js create mode 100644 vendors/DateJS/src/i18n/sr-Latn-CS.js create mode 100644 vendors/DateJS/src/i18n/sv-FI.js create mode 100644 vendors/DateJS/src/i18n/sv-SE.js create mode 100644 vendors/DateJS/src/i18n/sw-KE.js create mode 100644 vendors/DateJS/src/i18n/syr-SY.js create mode 100644 vendors/DateJS/src/i18n/ta-IN.js create mode 100644 vendors/DateJS/src/i18n/te-IN.js create mode 100644 vendors/DateJS/src/i18n/th-TH.js create mode 100644 vendors/DateJS/src/i18n/tn-ZA.js create mode 100644 vendors/DateJS/src/i18n/tr-TR.js create mode 100644 vendors/DateJS/src/i18n/tt-RU.js create mode 100644 vendors/DateJS/src/i18n/uk-UA.js create mode 100644 vendors/DateJS/src/i18n/ur-PK.js create mode 100644 vendors/DateJS/src/i18n/uz-Cyrl-UZ.js create mode 100644 vendors/DateJS/src/i18n/uz-Latn-UZ.js create mode 100644 vendors/DateJS/src/i18n/vi-VN.js create mode 100644 vendors/DateJS/src/i18n/xh-ZA.js create mode 100644 vendors/DateJS/src/i18n/zh-CN.js create mode 100644 vendors/DateJS/src/i18n/zh-HK.js create mode 100644 vendors/DateJS/src/i18n/zh-MO.js create mode 100644 vendors/DateJS/src/i18n/zh-SG.js create mode 100644 vendors/DateJS/src/i18n/zh-TW.js create mode 100644 vendors/DateJS/src/i18n/zu-ZA.js create mode 100644 vendors/flot-spline/.bower.json create mode 100644 vendors/flot-spline/LICENSE create mode 100644 vendors/flot-spline/bower.json create mode 100644 vendors/flot-spline/js/jquery.flot.spline.js create mode 100644 vendors/flot-spline/js/jquery.flot.spline.min.js create mode 100644 vendors/flot-spline/package.json create mode 100644 vendors/flot.curvedlines/.bower.json create mode 100644 vendors/flot.curvedlines/bower.json rename {production/js/flot => vendors/flot.curvedlines}/curvedLines.js (100%) mode change 100755 => 100644 create mode 100644 vendors/flot.orderbars/.bower.json create mode 100644 vendors/flot.orderbars/README.md create mode 100644 vendors/flot.orderbars/examples/index.html create mode 100644 vendors/flot.orderbars/examples/js/flot/flot.js create mode 100644 vendors/flot.orderbars/examples/js/flot/stack.js create mode 100644 vendors/flot.orderbars/examples/js/main.js create mode 100644 vendors/flot.orderbars/examples/js/vendor/jquery-1.9.1.min.js rename {production/js/flot => vendors/flot.orderbars/js}/jquery.flot.orderBars.js (100%) mode change 100755 => 100644 diff --git a/bower.json b/bower.json index 7853f06..b381199 100644 --- a/bower.json +++ b/bower.json @@ -74,7 +74,11 @@ "echarts": "^3.1.7", "malihu-custom-scrollbar-plugin": "^3.1.3", "animate.css": "^3.5.1", - "jqvmap": "https://github.com/christianesperar/jqvmap.git#master" + "jqvmap": "https://github.com/christianesperar/jqvmap.git#master", + "DateJS": "^1.0.0-rc3", + "flot.curvedlines": "^1.1.1", + "flot.orderbars": "*", + "flot-spline": "^0.8.2" }, "resolutions": { "jquery": "^2.2.3", diff --git a/production/index.html b/production/index.html index 16ea3d5..ded9368 100755 --- a/production/index.html +++ b/production/index.html @@ -1004,10 +1004,11 @@ - - - - + + + + + diff --git a/production/index2.html b/production/index2.html index 8659886..6b22d2d 100755 --- a/production/index2.html +++ b/production/index2.html @@ -754,10 +754,11 @@ - - - - + + + + + diff --git a/production/index3.html b/production/index3.html index 0e3bfd6..e3b5088 100755 --- a/production/index3.html +++ b/production/index3.html @@ -870,10 +870,11 @@ - - - - + + + + + diff --git a/production/js/flot/date.js b/production/js/flot/date.js deleted file mode 100755 index 77f4986..0000000 --- a/production/js/flot/date.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Version: 1.0 Alpha-1 - * Build Date: 13-Nov-2007 - * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. - * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. - * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ - */ -Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",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","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",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 GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,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)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}}; -Date.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;idate)?1:(this=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config=="number"){this._orient=config;return this;} -var x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);} -if(x.second||x.seconds){this.addSeconds(x.second||x.seconds);} -if(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);} -if(x.hour||x.hours){this.addHours(x.hour||x.hours);} -if(x.month||x.months){this.addMonths(x.month||x.months);} -if(x.year||x.years){this.addYears(x.year||x.years);} -if(x.day||x.days){this.addDays(x.day||x.days);} -return this;};Date._validate=function(value,min,max,name){if(typeof value!="number"){throw new TypeError(value+" is not a Number.");}else if(valuemax){throw new RangeError(value+" is not a valid value for "+name+".");} -return true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,"milliseconds");};Date.validateSecond=function(n){return Date._validate(n,0,59,"seconds");};Date.validateMinute=function(n){return Date._validate(n,0,59,"minutes");};Date.validateHour=function(n){return Date._validate(n,0,23,"hours");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),"days");};Date.validateMonth=function(n){return Date._validate(n,0,11,"months");};Date.validateYear=function(n){return Date._validate(n,1,9999,"seconds");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;} -if(!x.second&&x.second!==0){x.second=-1;} -if(!x.minute&&x.minute!==0){x.minute=-1;} -if(!x.hour&&x.hour!==0){x.hour=-1;} -if(!x.day&&x.day!==0){x.day=-1;} -if(!x.month&&x.month!==0){x.month=-1;} -if(!x.year&&x.year!==0){x.year=-1;} -if(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());} -if(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());} -if(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());} -if(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());} -if(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());} -if(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());} -if(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());} -if(x.timezone){this.setTimezone(x.timezone);} -if(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);} -return this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;} -var daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}} -return w;};Date.prototype.isDST=function(){console.log('isDST');return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?"0"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case"hh":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case"h":return self.getHours()<13?self.getHours():(self.getHours()-12);case"HH":return p(self.getHours());case"H":return self.getHours();case"mm":return p(self.getMinutes());case"m":return self.getMinutes();case"ss":return p(self.getSeconds());case"s":return self.getSeconds();case"yyyy":return self.getFullYear();case"yy":return self.getFullYear().toString().substring(2,4);case"dddd":return self.getDayName();case"ddd":return self.getDayName(true);case"dd":return p(self.getDate());case"d":return self.getDate().toString();case"MMMM":return self.getMonthName();case"MMM":return self.getMonthName(true);case"MM":return p((self.getMonth()+1));case"M":return self.getMonth()+1;case"t":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return"";}}):this._toString();}; -Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;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").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;} -return this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;} -if(!last&&q[1].length===0){last=true;} -if(!last){var qx=[];for(var j=0;j0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}} -if(rx[1].length1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];} -if(args){for(var i=0,px=args.shift();i2)?n:(n+(((n+2000)Date.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);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 - * modified by: Avi Kohn https://github.com/AMKohn - * based on the spline interpolation described at: - * http://scaledinnovation.com/analytics/splines/aboutSplines.html - * - * Example usage: (add in plot options series object) - * for linespline: - * series: { - * ... - * lines: { - * show: false - * }, - * splines: { - * show: true, - * tension: x, (float between 0 and 1, defaults to 0.5), - * lineWidth: y (number, defaults to 2), - * fill: z (float between 0 .. 1 or false, as in flot documentation) - * }, - * ... - * } - * areaspline: - * series: { - * ... - * lines: { - * show: true, - * lineWidth: 0, (line drawing will not execute) - * fill: x, (float between 0 .. 1, as in flot documentation) - * ... - * }, - * splines: { - * show: true, - * tension: 0.5 (float between 0 and 1) - * }, - * ... - * } - * - */ - -(function($) { - 'use strict' - - /** - * @param {Number} x0, y0, x1, y1: coordinates of the end (knot) points of the segment - * @param {Number} x2, y2: the next knot (not connected, but needed to calculate p2) - * @param {Number} tension: control how far the control points spread - * @return {Array}: p1 -> control point, from x1 back toward x0 - * p2 -> the next control point, returned to become the next segment's p1 - * - * @api private - */ - function getControlPoints(x0, y0, x1, y1, x2, y2, tension) { - - var pow = Math.pow, - sqrt = Math.sqrt, - d01, d12, fa, fb, p1x, p1y, p2x, p2y; - - // Scaling factors: distances from this knot to the previous and following knots. - d01 = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2)); - d12 = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); - - fa = tension * d01 / (d01 + d12); - fb = tension - fa; - - p1x = x1 + fa * (x0 - x2); - p1y = y1 + fa * (y0 - y2); - - p2x = x1 - fb * (x0 - x2); - p2y = y1 - fb * (y0 - y2); - - return [p1x, p1y, p2x, p2y]; - } - - var line = []; - - function drawLine(points, ctx, height, fill, seriesColor) { - var c = $.color.parse(seriesColor); - - c.a = typeof fill == "number" ? fill : .3; - c.normalize(); - c = c.toString(); - - ctx.beginPath(); - ctx.moveTo(points[0][0], points[0][1]); - - var plength = points.length; - - for (var i = 0; i < plength; i++) { - ctx[points[i][3]].apply(ctx, points[i][2]); - } - - ctx.stroke(); - - ctx.lineWidth = 0; - ctx.lineTo(points[plength - 1][0], height); - ctx.lineTo(points[0][0], height); - - ctx.closePath(); - - if (fill !== false) { - ctx.fillStyle = c; - ctx.fill(); - } - } - - /** - * @param {Object} ctx: canvas context - * @param {String} type: accepted strings: 'bezier' or 'quadratic' (defaults to quadratic) - * @param {Array} points: 2 points for which to draw the interpolation - * @param {Array} cpoints: control points for those segment points - * - * @api private - */ - function queue(ctx, type, points, cpoints) { - if (type === void 0 || (type !== 'bezier' && type !== 'quadratic')) { - type = 'quadratic'; - } - type = type + 'CurveTo'; - - if (line.length == 0) line.push([points[0], points[1], cpoints.concat(points.slice(2)), type]); - else if (type == "quadraticCurveTo" && points.length == 2) { - cpoints = cpoints.slice(0, 2).concat(points); - - line.push([points[0], points[1], cpoints, type]); - } - else line.push([points[2], points[3], cpoints.concat(points.slice(2)), type]); - } - - /** - * @param {Object} plot - * @param {Object} ctx: canvas context - * @param {Object} series - * - * @api private - */ - - function drawSpline(plot, ctx, series) { - // Not interested if spline is not requested - if (series.splines.show !== true) { - return; - } - - var cp = [], - // array of control points - tension = series.splines.tension || 0.5, - idx, x, y, points = series.datapoints.points, - ps = series.datapoints.pointsize, - plotOffset = plot.getPlotOffset(), - len = points.length, - pts = []; - - line = []; - - // Cannot display a linespline/areaspline if there are less than 3 points - if (len / ps < 4) { - $.extend(series.lines, series.splines); - return; - } - - for (idx = 0; idx < len; idx += ps) { - x = points[idx]; - y = points[idx + 1]; - if (x == null || x < series.xaxis.min || x > series.xaxis.max || y < series.yaxis.min || y > series.yaxis.max) { - continue; - } - - pts.push(series.xaxis.p2c(x) + plotOffset.left, series.yaxis.p2c(y) + plotOffset.top); - } - - len = pts.length; - - // Draw an open curve, not connected at the ends - for (idx = 0; idx < len - 2; idx += 2) { - cp = cp.concat(getControlPoints.apply(this, pts.slice(idx, idx + 6).concat([tension]))); - } - - ctx.save(); - ctx.strokeStyle = series.color; - ctx.lineWidth = series.splines.lineWidth; - - queue(ctx, 'quadratic', pts.slice(0, 4), cp.slice(0, 2)); - - for (idx = 2; idx < len - 3; idx += 2) { - queue(ctx, 'bezier', pts.slice(idx, idx + 4), cp.slice(2 * idx - 2, 2 * idx + 2)); - } - - queue(ctx, 'quadratic', pts.slice(len - 2, len), [cp[2 * len - 10], cp[2 * len - 9], pts[len - 4], pts[len - 3]]); - - drawLine(line, ctx, plot.height() + 10, series.splines.fill, series.color); - - ctx.restore(); - } - - $.plot.plugins.push({ - init: function(plot) { - plot.hooks.drawSeries.push(drawSpline); - }, - options: { - series: { - splines: { - show: false, - lineWidth: 2, - tension: 0.5, - fill: false - } - } - }, - name: 'spline', - version: '0.8.2' - }); -})(jQuery); diff --git a/vendors/DateJS/.bower.json b/vendors/DateJS/.bower.json new file mode 100644 index 0000000..699b325 --- /dev/null +++ b/vendors/DateJS/.bower.json @@ -0,0 +1,35 @@ +{ + "name": "DateJS", + "version": "1.0.0-rc3", + "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" + ], + "_release": "1.0.0-rc3", + "_resolution": { + "type": "version", + "tag": "v1.0.0-rc3", + "commit": "a173b13c148b8b257c0ca58dea90cb7ad616f35b" + }, + "_source": "https://github.com/abritinthebay/datejs.git", + "_target": "^1.0.0-rc3", + "_originalSource": "DateJS", + "_direct": true +} \ No newline at end of file diff --git a/vendors/DateJS/GruntFile.js b/vendors/DateJS/GruntFile.js new file mode 100644 index 0000000..c78bca8 --- /dev/null +++ b/vendors/DateJS/GruntFile.js @@ -0,0 +1,184 @@ +// 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"]); +}; \ No newline at end of file diff --git a/vendors/DateJS/LICENSE b/vendors/DateJS/LICENSE new file mode 100644 index 0000000..6f7a829 --- /dev/null +++ b/vendors/DateJS/LICENSE @@ -0,0 +1,21 @@ +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. diff --git a/vendors/DateJS/README.md b/vendors/DateJS/README.md new file mode 100644 index 0000000..b195e99 --- /dev/null +++ b/vendors/DateJS/README.md @@ -0,0 +1,48 @@ +# 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) + +[![NPM](https://nodei.co/npm/datejs.png?downloadRank=true)](https://nodei.co/npm/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 + +#### 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 +In Node.js you can just call `Date.i18n.setLanguage` with the IETF appropriate code (e.g. "de-DE", or "es-MX") and DateJS will load the file automatically. For the browser DateJS has langauge support in one of two ways: + 1. Either 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). + 2. Or 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 script element insertion. + +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 + * `development` 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](http://pivotal.github.io/jasmine/). Code coverage is calculated by [BlanketJS](http://blanketjs.org/). +* `tests` Orginal unit tests for 2008 project. *Deprecated* diff --git a/vendors/DateJS/bower.json b/vendors/DateJS/bower.json new file mode 100644 index 0000000..f27e16b --- /dev/null +++ b/vendors/DateJS/bower.json @@ -0,0 +1,25 @@ +{ + "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" + ] +} diff --git a/vendors/DateJS/build/date-af-ZA.js b/vendors/DateJS/build/date-af-ZA.js new file mode 100644 index 0000000..d6645bc --- /dev/null +++ b/vendors/DateJS/build/date-af-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-AE.js b/vendors/DateJS/build/date-ar-AE.js new file mode 100644 index 0000000..330c843 --- /dev/null +++ b/vendors/DateJS/build/date-ar-AE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-BH.js b/vendors/DateJS/build/date-ar-BH.js new file mode 100644 index 0000000..37ca5d0 --- /dev/null +++ b/vendors/DateJS/build/date-ar-BH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-DZ.js b/vendors/DateJS/build/date-ar-DZ.js new file mode 100644 index 0000000..41fad4d --- /dev/null +++ b/vendors/DateJS/build/date-ar-DZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-EG.js b/vendors/DateJS/build/date-ar-EG.js new file mode 100644 index 0000000..5e69239 --- /dev/null +++ b/vendors/DateJS/build/date-ar-EG.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-IQ.js b/vendors/DateJS/build/date-ar-IQ.js new file mode 100644 index 0000000..eab5a5d --- /dev/null +++ b/vendors/DateJS/build/date-ar-IQ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-JO.js b/vendors/DateJS/build/date-ar-JO.js new file mode 100644 index 0000000..04aebb8 --- /dev/null +++ b/vendors/DateJS/build/date-ar-JO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-KW.js b/vendors/DateJS/build/date-ar-KW.js new file mode 100644 index 0000000..8a7abbd --- /dev/null +++ b/vendors/DateJS/build/date-ar-KW.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-LB.js b/vendors/DateJS/build/date-ar-LB.js new file mode 100644 index 0000000..b977d45 --- /dev/null +++ b/vendors/DateJS/build/date-ar-LB.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-LY.js b/vendors/DateJS/build/date-ar-LY.js new file mode 100644 index 0000000..0dcbfad --- /dev/null +++ b/vendors/DateJS/build/date-ar-LY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-MA.js b/vendors/DateJS/build/date-ar-MA.js new file mode 100644 index 0000000..811fc33 --- /dev/null +++ b/vendors/DateJS/build/date-ar-MA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-OM.js b/vendors/DateJS/build/date-ar-OM.js new file mode 100644 index 0000000..38c6804 --- /dev/null +++ b/vendors/DateJS/build/date-ar-OM.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-QA.js b/vendors/DateJS/build/date-ar-QA.js new file mode 100644 index 0000000..71677cc --- /dev/null +++ b/vendors/DateJS/build/date-ar-QA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-SA.js b/vendors/DateJS/build/date-ar-SA.js new file mode 100644 index 0000000..0947ac1 --- /dev/null +++ b/vendors/DateJS/build/date-ar-SA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-SY.js b/vendors/DateJS/build/date-ar-SY.js new file mode 100644 index 0000000..d7a8051 --- /dev/null +++ b/vendors/DateJS/build/date-ar-SY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-TN.js b/vendors/DateJS/build/date-ar-TN.js new file mode 100644 index 0000000..a10039a --- /dev/null +++ b/vendors/DateJS/build/date-ar-TN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ar-YE.js b/vendors/DateJS/build/date-ar-YE.js new file mode 100644 index 0000000..bbbb920 --- /dev/null +++ b/vendors/DateJS/build/date-ar-YE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-az-Cyrl-AZ.js b/vendors/DateJS/build/date-az-Cyrl-AZ.js new file mode 100644 index 0000000..c3f5146 --- /dev/null +++ b/vendors/DateJS/build/date-az-Cyrl-AZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-az-Latn-AZ.js b/vendors/DateJS/build/date-az-Latn-AZ.js new file mode 100644 index 0000000..b1f747e --- /dev/null +++ b/vendors/DateJS/build/date-az-Latn-AZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-be-BY.js b/vendors/DateJS/build/date-be-BY.js new file mode 100644 index 0000000..28df467 --- /dev/null +++ b/vendors/DateJS/build/date-be-BY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-bg-BG.js b/vendors/DateJS/build/date-bg-BG.js new file mode 100644 index 0000000..4147c0c --- /dev/null +++ b/vendors/DateJS/build/date-bg-BG.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-bs-Latn-BA.js b/vendors/DateJS/build/date-bs-Latn-BA.js new file mode 100644 index 0000000..ada330a --- /dev/null +++ b/vendors/DateJS/build/date-bs-Latn-BA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ca-ES.js b/vendors/DateJS/build/date-ca-ES.js new file mode 100644 index 0000000..0e24cea --- /dev/null +++ b/vendors/DateJS/build/date-ca-ES.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-cs-CZ.js b/vendors/DateJS/build/date-cs-CZ.js new file mode 100644 index 0000000..0e09c77 --- /dev/null +++ b/vendors/DateJS/build/date-cs-CZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-cy-GB.js b/vendors/DateJS/build/date-cy-GB.js new file mode 100644 index 0000000..6150570 --- /dev/null +++ b/vendors/DateJS/build/date-cy-GB.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-da-DK.js b/vendors/DateJS/build/date-da-DK.js new file mode 100644 index 0000000..cf6a886 --- /dev/null +++ b/vendors/DateJS/build/date-da-DK.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-de-AT.js b/vendors/DateJS/build/date-de-AT.js new file mode 100644 index 0000000..e288047 --- /dev/null +++ b/vendors/DateJS/build/date-de-AT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-de-CH.js b/vendors/DateJS/build/date-de-CH.js new file mode 100644 index 0000000..4e231c9 --- /dev/null +++ b/vendors/DateJS/build/date-de-CH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-de-DE.js b/vendors/DateJS/build/date-de-DE.js new file mode 100644 index 0000000..964e7cc --- /dev/null +++ b/vendors/DateJS/build/date-de-DE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-de-LI.js b/vendors/DateJS/build/date-de-LI.js new file mode 100644 index 0000000..8e70b81 --- /dev/null +++ b/vendors/DateJS/build/date-de-LI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-de-LU.js b/vendors/DateJS/build/date-de-LU.js new file mode 100644 index 0000000..14adf96 --- /dev/null +++ b/vendors/DateJS/build/date-de-LU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-dv-MV.js b/vendors/DateJS/build/date-dv-MV.js new file mode 100644 index 0000000..052777e --- /dev/null +++ b/vendors/DateJS/build/date-dv-MV.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-el-GR.js b/vendors/DateJS/build/date-el-GR.js new file mode 100644 index 0000000..eab9e3b --- /dev/null +++ b/vendors/DateJS/build/date-el-GR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-029.js b/vendors/DateJS/build/date-en-029.js new file mode 100644 index 0000000..841d6a6 --- /dev/null +++ b/vendors/DateJS/build/date-en-029.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-AU.js b/vendors/DateJS/build/date-en-AU.js new file mode 100644 index 0000000..a364990 --- /dev/null +++ b/vendors/DateJS/build/date-en-AU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-BZ.js b/vendors/DateJS/build/date-en-BZ.js new file mode 100644 index 0000000..79b3d5c --- /dev/null +++ b/vendors/DateJS/build/date-en-BZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-CA.js b/vendors/DateJS/build/date-en-CA.js new file mode 100644 index 0000000..1a7edbc --- /dev/null +++ b/vendors/DateJS/build/date-en-CA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-GB.js b/vendors/DateJS/build/date-en-GB.js new file mode 100644 index 0000000..601613d --- /dev/null +++ b/vendors/DateJS/build/date-en-GB.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-IE.js b/vendors/DateJS/build/date-en-IE.js new file mode 100644 index 0000000..c2fc858 --- /dev/null +++ b/vendors/DateJS/build/date-en-IE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-JM.js b/vendors/DateJS/build/date-en-JM.js new file mode 100644 index 0000000..41b2da5 --- /dev/null +++ b/vendors/DateJS/build/date-en-JM.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-NZ.js b/vendors/DateJS/build/date-en-NZ.js new file mode 100644 index 0000000..1d7346e --- /dev/null +++ b/vendors/DateJS/build/date-en-NZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-PH.js b/vendors/DateJS/build/date-en-PH.js new file mode 100644 index 0000000..77b39f5 --- /dev/null +++ b/vendors/DateJS/build/date-en-PH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-TT.js b/vendors/DateJS/build/date-en-TT.js new file mode 100644 index 0000000..fc3c91b --- /dev/null +++ b/vendors/DateJS/build/date-en-TT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-US.js b/vendors/DateJS/build/date-en-US.js new file mode 100644 index 0000000..0ce137a --- /dev/null +++ b/vendors/DateJS/build/date-en-US.js @@ -0,0 +1,4096 @@ +/** + * @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; +}; \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-ZA.js b/vendors/DateJS/build/date-en-ZA.js new file mode 100644 index 0000000..34f2523 --- /dev/null +++ b/vendors/DateJS/build/date-en-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-en-ZW.js b/vendors/DateJS/build/date-en-ZW.js new file mode 100644 index 0000000..d33dfd5 --- /dev/null +++ b/vendors/DateJS/build/date-en-ZW.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-AR.js b/vendors/DateJS/build/date-es-AR.js new file mode 100644 index 0000000..7c33751 --- /dev/null +++ b/vendors/DateJS/build/date-es-AR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-BO.js b/vendors/DateJS/build/date-es-BO.js new file mode 100644 index 0000000..237ddd8 --- /dev/null +++ b/vendors/DateJS/build/date-es-BO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-CL.js b/vendors/DateJS/build/date-es-CL.js new file mode 100644 index 0000000..b729322 --- /dev/null +++ b/vendors/DateJS/build/date-es-CL.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-CO.js b/vendors/DateJS/build/date-es-CO.js new file mode 100644 index 0000000..e0a549b --- /dev/null +++ b/vendors/DateJS/build/date-es-CO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-CR.js b/vendors/DateJS/build/date-es-CR.js new file mode 100644 index 0000000..ca53f55 --- /dev/null +++ b/vendors/DateJS/build/date-es-CR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-DO.js b/vendors/DateJS/build/date-es-DO.js new file mode 100644 index 0000000..b44fb79 --- /dev/null +++ b/vendors/DateJS/build/date-es-DO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-EC.js b/vendors/DateJS/build/date-es-EC.js new file mode 100644 index 0000000..bf7c371 --- /dev/null +++ b/vendors/DateJS/build/date-es-EC.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-ES.js b/vendors/DateJS/build/date-es-ES.js new file mode 100644 index 0000000..11d5302 --- /dev/null +++ b/vendors/DateJS/build/date-es-ES.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-GT.js b/vendors/DateJS/build/date-es-GT.js new file mode 100644 index 0000000..bb680e1 --- /dev/null +++ b/vendors/DateJS/build/date-es-GT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-HN.js b/vendors/DateJS/build/date-es-HN.js new file mode 100644 index 0000000..9b4f83c --- /dev/null +++ b/vendors/DateJS/build/date-es-HN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-MX.js b/vendors/DateJS/build/date-es-MX.js new file mode 100644 index 0000000..a9dc0f3 --- /dev/null +++ b/vendors/DateJS/build/date-es-MX.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-NI.js b/vendors/DateJS/build/date-es-NI.js new file mode 100644 index 0000000..53d330d --- /dev/null +++ b/vendors/DateJS/build/date-es-NI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-PA.js b/vendors/DateJS/build/date-es-PA.js new file mode 100644 index 0000000..de9e8f6 --- /dev/null +++ b/vendors/DateJS/build/date-es-PA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-PE.js b/vendors/DateJS/build/date-es-PE.js new file mode 100644 index 0000000..72c4608 --- /dev/null +++ b/vendors/DateJS/build/date-es-PE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-PR.js b/vendors/DateJS/build/date-es-PR.js new file mode 100644 index 0000000..bff6a29 --- /dev/null +++ b/vendors/DateJS/build/date-es-PR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-PY.js b/vendors/DateJS/build/date-es-PY.js new file mode 100644 index 0000000..8340350 --- /dev/null +++ b/vendors/DateJS/build/date-es-PY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-SV.js b/vendors/DateJS/build/date-es-SV.js new file mode 100644 index 0000000..f713b96 --- /dev/null +++ b/vendors/DateJS/build/date-es-SV.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-UY.js b/vendors/DateJS/build/date-es-UY.js new file mode 100644 index 0000000..265c95c --- /dev/null +++ b/vendors/DateJS/build/date-es-UY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-es-VE.js b/vendors/DateJS/build/date-es-VE.js new file mode 100644 index 0000000..48ce6e6 --- /dev/null +++ b/vendors/DateJS/build/date-es-VE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-et-EE.js b/vendors/DateJS/build/date-et-EE.js new file mode 100644 index 0000000..611c897 --- /dev/null +++ b/vendors/DateJS/build/date-et-EE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-eu-ES.js b/vendors/DateJS/build/date-eu-ES.js new file mode 100644 index 0000000..b13e08f --- /dev/null +++ b/vendors/DateJS/build/date-eu-ES.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fa-IR.js b/vendors/DateJS/build/date-fa-IR.js new file mode 100644 index 0000000..d7777e9 --- /dev/null +++ b/vendors/DateJS/build/date-fa-IR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fi-FI.js b/vendors/DateJS/build/date-fi-FI.js new file mode 100644 index 0000000..7962642 --- /dev/null +++ b/vendors/DateJS/build/date-fi-FI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fo-FO.js b/vendors/DateJS/build/date-fo-FO.js new file mode 100644 index 0000000..2d6fb99 --- /dev/null +++ b/vendors/DateJS/build/date-fo-FO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-BE.js b/vendors/DateJS/build/date-fr-BE.js new file mode 100644 index 0000000..90c9b8e --- /dev/null +++ b/vendors/DateJS/build/date-fr-BE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-CA.js b/vendors/DateJS/build/date-fr-CA.js new file mode 100644 index 0000000..3c3cca3 --- /dev/null +++ b/vendors/DateJS/build/date-fr-CA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-CH.js b/vendors/DateJS/build/date-fr-CH.js new file mode 100644 index 0000000..7a668f4 --- /dev/null +++ b/vendors/DateJS/build/date-fr-CH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-FR.js b/vendors/DateJS/build/date-fr-FR.js new file mode 100644 index 0000000..c355664 --- /dev/null +++ b/vendors/DateJS/build/date-fr-FR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-LU.js b/vendors/DateJS/build/date-fr-LU.js new file mode 100644 index 0000000..c5b2096 --- /dev/null +++ b/vendors/DateJS/build/date-fr-LU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-fr-MC.js b/vendors/DateJS/build/date-fr-MC.js new file mode 100644 index 0000000..5abf61f --- /dev/null +++ b/vendors/DateJS/build/date-fr-MC.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-gl-ES.js b/vendors/DateJS/build/date-gl-ES.js new file mode 100644 index 0000000..c91414e --- /dev/null +++ b/vendors/DateJS/build/date-gl-ES.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-gu-IN.js b/vendors/DateJS/build/date-gu-IN.js new file mode 100644 index 0000000..2394185 --- /dev/null +++ b/vendors/DateJS/build/date-gu-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-he-IL.js b/vendors/DateJS/build/date-he-IL.js new file mode 100644 index 0000000..88db194 --- /dev/null +++ b/vendors/DateJS/build/date-he-IL.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-hi-IN.js b/vendors/DateJS/build/date-hi-IN.js new file mode 100644 index 0000000..06c8437 --- /dev/null +++ b/vendors/DateJS/build/date-hi-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-hr-BA.js b/vendors/DateJS/build/date-hr-BA.js new file mode 100644 index 0000000..93276d1 --- /dev/null +++ b/vendors/DateJS/build/date-hr-BA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-hr-HR.js b/vendors/DateJS/build/date-hr-HR.js new file mode 100644 index 0000000..9267798 --- /dev/null +++ b/vendors/DateJS/build/date-hr-HR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-hu-HU.js b/vendors/DateJS/build/date-hu-HU.js new file mode 100644 index 0000000..9b8717c --- /dev/null +++ b/vendors/DateJS/build/date-hu-HU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-hy-AM.js b/vendors/DateJS/build/date-hy-AM.js new file mode 100644 index 0000000..425ac6a --- /dev/null +++ b/vendors/DateJS/build/date-hy-AM.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-id-ID.js b/vendors/DateJS/build/date-id-ID.js new file mode 100644 index 0000000..d58fc97 --- /dev/null +++ b/vendors/DateJS/build/date-id-ID.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-is-IS.js b/vendors/DateJS/build/date-is-IS.js new file mode 100644 index 0000000..895413e --- /dev/null +++ b/vendors/DateJS/build/date-is-IS.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-it-CH.js b/vendors/DateJS/build/date-it-CH.js new file mode 100644 index 0000000..d50e1c5 --- /dev/null +++ b/vendors/DateJS/build/date-it-CH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-it-IT.js b/vendors/DateJS/build/date-it-IT.js new file mode 100644 index 0000000..0c6b826 --- /dev/null +++ b/vendors/DateJS/build/date-it-IT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ja-JP.js b/vendors/DateJS/build/date-ja-JP.js new file mode 100644 index 0000000..e7f6d76 --- /dev/null +++ b/vendors/DateJS/build/date-ja-JP.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ka-GE.js b/vendors/DateJS/build/date-ka-GE.js new file mode 100644 index 0000000..57a05c9 --- /dev/null +++ b/vendors/DateJS/build/date-ka-GE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-kk-KZ.js b/vendors/DateJS/build/date-kk-KZ.js new file mode 100644 index 0000000..35d39b4 --- /dev/null +++ b/vendors/DateJS/build/date-kk-KZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-kn-IN.js b/vendors/DateJS/build/date-kn-IN.js new file mode 100644 index 0000000..c139397 --- /dev/null +++ b/vendors/DateJS/build/date-kn-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ko-KR.js b/vendors/DateJS/build/date-ko-KR.js new file mode 100644 index 0000000..7979813 --- /dev/null +++ b/vendors/DateJS/build/date-ko-KR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-kok-IN.js b/vendors/DateJS/build/date-kok-IN.js new file mode 100644 index 0000000..f47b7e5 --- /dev/null +++ b/vendors/DateJS/build/date-kok-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ky-KG.js b/vendors/DateJS/build/date-ky-KG.js new file mode 100644 index 0000000..e375a2c --- /dev/null +++ b/vendors/DateJS/build/date-ky-KG.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-lt-LT.js b/vendors/DateJS/build/date-lt-LT.js new file mode 100644 index 0000000..b4e853e --- /dev/null +++ b/vendors/DateJS/build/date-lt-LT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-lv-LV.js b/vendors/DateJS/build/date-lv-LV.js new file mode 100644 index 0000000..8baa085 --- /dev/null +++ b/vendors/DateJS/build/date-lv-LV.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-mi-NZ.js b/vendors/DateJS/build/date-mi-NZ.js new file mode 100644 index 0000000..2dbb9a0 --- /dev/null +++ b/vendors/DateJS/build/date-mi-NZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-mk-MK.js b/vendors/DateJS/build/date-mk-MK.js new file mode 100644 index 0000000..861124e --- /dev/null +++ b/vendors/DateJS/build/date-mk-MK.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-mn-MN.js b/vendors/DateJS/build/date-mn-MN.js new file mode 100644 index 0000000..64d3938 --- /dev/null +++ b/vendors/DateJS/build/date-mn-MN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-mr-IN.js b/vendors/DateJS/build/date-mr-IN.js new file mode 100644 index 0000000..c45ed09 --- /dev/null +++ b/vendors/DateJS/build/date-mr-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ms-BN.js b/vendors/DateJS/build/date-ms-BN.js new file mode 100644 index 0000000..7a284ec --- /dev/null +++ b/vendors/DateJS/build/date-ms-BN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ms-MY.js b/vendors/DateJS/build/date-ms-MY.js new file mode 100644 index 0000000..82624d6 --- /dev/null +++ b/vendors/DateJS/build/date-ms-MY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-mt-MT.js b/vendors/DateJS/build/date-mt-MT.js new file mode 100644 index 0000000..62c5612 --- /dev/null +++ b/vendors/DateJS/build/date-mt-MT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-nb-NO.js b/vendors/DateJS/build/date-nb-NO.js new file mode 100644 index 0000000..b5e6bf6 --- /dev/null +++ b/vendors/DateJS/build/date-nb-NO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-nl-BE.js b/vendors/DateJS/build/date-nl-BE.js new file mode 100644 index 0000000..b5cafc8 --- /dev/null +++ b/vendors/DateJS/build/date-nl-BE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-nl-NL.js b/vendors/DateJS/build/date-nl-NL.js new file mode 100644 index 0000000..4ced487 --- /dev/null +++ b/vendors/DateJS/build/date-nl-NL.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-nn-NO.js b/vendors/DateJS/build/date-nn-NO.js new file mode 100644 index 0000000..98a3de8 --- /dev/null +++ b/vendors/DateJS/build/date-nn-NO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ns-ZA.js b/vendors/DateJS/build/date-ns-ZA.js new file mode 100644 index 0000000..7d3175e --- /dev/null +++ b/vendors/DateJS/build/date-ns-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-pa-IN.js b/vendors/DateJS/build/date-pa-IN.js new file mode 100644 index 0000000..6b730f7 --- /dev/null +++ b/vendors/DateJS/build/date-pa-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-pl-PL.js b/vendors/DateJS/build/date-pl-PL.js new file mode 100644 index 0000000..893ba72 --- /dev/null +++ b/vendors/DateJS/build/date-pl-PL.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-pt-BR.js b/vendors/DateJS/build/date-pt-BR.js new file mode 100644 index 0000000..83aebbd --- /dev/null +++ b/vendors/DateJS/build/date-pt-BR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-pt-PT.js b/vendors/DateJS/build/date-pt-PT.js new file mode 100644 index 0000000..1f4a380 --- /dev/null +++ b/vendors/DateJS/build/date-pt-PT.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-quz-BO.js b/vendors/DateJS/build/date-quz-BO.js new file mode 100644 index 0000000..9fc3274 --- /dev/null +++ b/vendors/DateJS/build/date-quz-BO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-quz-EC.js b/vendors/DateJS/build/date-quz-EC.js new file mode 100644 index 0000000..f0df98f --- /dev/null +++ b/vendors/DateJS/build/date-quz-EC.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-quz-PE.js b/vendors/DateJS/build/date-quz-PE.js new file mode 100644 index 0000000..df5bc63 --- /dev/null +++ b/vendors/DateJS/build/date-quz-PE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ro-RO.js b/vendors/DateJS/build/date-ro-RO.js new file mode 100644 index 0000000..fe934b9 --- /dev/null +++ b/vendors/DateJS/build/date-ro-RO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ru-RU.js b/vendors/DateJS/build/date-ru-RU.js new file mode 100644 index 0000000..ca16cb6 --- /dev/null +++ b/vendors/DateJS/build/date-ru-RU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sa-IN.js b/vendors/DateJS/build/date-sa-IN.js new file mode 100644 index 0000000..c43ab62 --- /dev/null +++ b/vendors/DateJS/build/date-sa-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-se-FI.js b/vendors/DateJS/build/date-se-FI.js new file mode 100644 index 0000000..dd57864 --- /dev/null +++ b/vendors/DateJS/build/date-se-FI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-se-NO.js b/vendors/DateJS/build/date-se-NO.js new file mode 100644 index 0000000..120de3c --- /dev/null +++ b/vendors/DateJS/build/date-se-NO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-se-SE.js b/vendors/DateJS/build/date-se-SE.js new file mode 100644 index 0000000..b56ff77 --- /dev/null +++ b/vendors/DateJS/build/date-se-SE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sk-SK.js b/vendors/DateJS/build/date-sk-SK.js new file mode 100644 index 0000000..f6d9d61 --- /dev/null +++ b/vendors/DateJS/build/date-sk-SK.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sl-SI.js b/vendors/DateJS/build/date-sl-SI.js new file mode 100644 index 0000000..774926e --- /dev/null +++ b/vendors/DateJS/build/date-sl-SI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sma-NO.js b/vendors/DateJS/build/date-sma-NO.js new file mode 100644 index 0000000..6c99e70 --- /dev/null +++ b/vendors/DateJS/build/date-sma-NO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sma-SE.js b/vendors/DateJS/build/date-sma-SE.js new file mode 100644 index 0000000..bbd0b0b --- /dev/null +++ b/vendors/DateJS/build/date-sma-SE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-smj-NO.js b/vendors/DateJS/build/date-smj-NO.js new file mode 100644 index 0000000..1d53e9a --- /dev/null +++ b/vendors/DateJS/build/date-smj-NO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-smj-SE.js b/vendors/DateJS/build/date-smj-SE.js new file mode 100644 index 0000000..d0872de --- /dev/null +++ b/vendors/DateJS/build/date-smj-SE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-smn-FI.js b/vendors/DateJS/build/date-smn-FI.js new file mode 100644 index 0000000..74a2448 --- /dev/null +++ b/vendors/DateJS/build/date-smn-FI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sms-FI.js b/vendors/DateJS/build/date-sms-FI.js new file mode 100644 index 0000000..b488819 --- /dev/null +++ b/vendors/DateJS/build/date-sms-FI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sq-AL.js b/vendors/DateJS/build/date-sq-AL.js new file mode 100644 index 0000000..14d06c7 --- /dev/null +++ b/vendors/DateJS/build/date-sq-AL.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sr-Cyrl-BA.js b/vendors/DateJS/build/date-sr-Cyrl-BA.js new file mode 100644 index 0000000..85b8c3d --- /dev/null +++ b/vendors/DateJS/build/date-sr-Cyrl-BA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sr-Cyrl-CS.js b/vendors/DateJS/build/date-sr-Cyrl-CS.js new file mode 100644 index 0000000..9a148cd --- /dev/null +++ b/vendors/DateJS/build/date-sr-Cyrl-CS.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sr-Latn-BA.js b/vendors/DateJS/build/date-sr-Latn-BA.js new file mode 100644 index 0000000..3853bc6 --- /dev/null +++ b/vendors/DateJS/build/date-sr-Latn-BA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sr-Latn-CS.js b/vendors/DateJS/build/date-sr-Latn-CS.js new file mode 100644 index 0000000..9800b9d --- /dev/null +++ b/vendors/DateJS/build/date-sr-Latn-CS.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sv-FI.js b/vendors/DateJS/build/date-sv-FI.js new file mode 100644 index 0000000..412df30 --- /dev/null +++ b/vendors/DateJS/build/date-sv-FI.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sv-SE.js b/vendors/DateJS/build/date-sv-SE.js new file mode 100644 index 0000000..ecb071b --- /dev/null +++ b/vendors/DateJS/build/date-sv-SE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-sw-KE.js b/vendors/DateJS/build/date-sw-KE.js new file mode 100644 index 0000000..1705b3e --- /dev/null +++ b/vendors/DateJS/build/date-sw-KE.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-syr-SY.js b/vendors/DateJS/build/date-syr-SY.js new file mode 100644 index 0000000..0552e43 --- /dev/null +++ b/vendors/DateJS/build/date-syr-SY.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ta-IN.js b/vendors/DateJS/build/date-ta-IN.js new file mode 100644 index 0000000..56b0a0a --- /dev/null +++ b/vendors/DateJS/build/date-ta-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-te-IN.js b/vendors/DateJS/build/date-te-IN.js new file mode 100644 index 0000000..873dd4c --- /dev/null +++ b/vendors/DateJS/build/date-te-IN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-th-TH.js b/vendors/DateJS/build/date-th-TH.js new file mode 100644 index 0000000..b3056b7 --- /dev/null +++ b/vendors/DateJS/build/date-th-TH.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-tn-ZA.js b/vendors/DateJS/build/date-tn-ZA.js new file mode 100644 index 0000000..2f13360 --- /dev/null +++ b/vendors/DateJS/build/date-tn-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-tr-TR.js b/vendors/DateJS/build/date-tr-TR.js new file mode 100644 index 0000000..d1f1f61 --- /dev/null +++ b/vendors/DateJS/build/date-tr-TR.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-tt-RU.js b/vendors/DateJS/build/date-tt-RU.js new file mode 100644 index 0000000..e3d52d7 --- /dev/null +++ b/vendors/DateJS/build/date-tt-RU.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-uk-UA.js b/vendors/DateJS/build/date-uk-UA.js new file mode 100644 index 0000000..625bec2 --- /dev/null +++ b/vendors/DateJS/build/date-uk-UA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-ur-PK.js b/vendors/DateJS/build/date-ur-PK.js new file mode 100644 index 0000000..aa0db34 --- /dev/null +++ b/vendors/DateJS/build/date-ur-PK.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-uz-Cyrl-UZ.js b/vendors/DateJS/build/date-uz-Cyrl-UZ.js new file mode 100644 index 0000000..ee3b457 --- /dev/null +++ b/vendors/DateJS/build/date-uz-Cyrl-UZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-uz-Latn-UZ.js b/vendors/DateJS/build/date-uz-Latn-UZ.js new file mode 100644 index 0000000..4b5c85f --- /dev/null +++ b/vendors/DateJS/build/date-uz-Latn-UZ.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-vi-VN.js b/vendors/DateJS/build/date-vi-VN.js new file mode 100644 index 0000000..9baa9ee --- /dev/null +++ b/vendors/DateJS/build/date-vi-VN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-xh-ZA.js b/vendors/DateJS/build/date-xh-ZA.js new file mode 100644 index 0000000..8b6e17d --- /dev/null +++ b/vendors/DateJS/build/date-xh-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zh-CN.js b/vendors/DateJS/build/date-zh-CN.js new file mode 100644 index 0000000..e26fd4c --- /dev/null +++ b/vendors/DateJS/build/date-zh-CN.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zh-HK.js b/vendors/DateJS/build/date-zh-HK.js new file mode 100644 index 0000000..c3e0e1a --- /dev/null +++ b/vendors/DateJS/build/date-zh-HK.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zh-MO.js b/vendors/DateJS/build/date-zh-MO.js new file mode 100644 index 0000000..1d44b9d --- /dev/null +++ b/vendors/DateJS/build/date-zh-MO.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zh-SG.js b/vendors/DateJS/build/date-zh-SG.js new file mode 100644 index 0000000..ccf6558 --- /dev/null +++ b/vendors/DateJS/build/date-zh-SG.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zh-TW.js b/vendors/DateJS/build/date-zh-TW.js new file mode 100644 index 0000000..05d6421 --- /dev/null +++ b/vendors/DateJS/build/date-zh-TW.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date-zu-ZA.js b/vendors/DateJS/build/date-zu-ZA.js new file mode 100644 index 0000000..e706eda --- /dev/null +++ b/vendors/DateJS/build/date-zu-ZA.js @@ -0,0 +1,4526 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 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 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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/date.js b/vendors/DateJS/build/date.js new file mode 100644 index 0000000..b37076d --- /dev/null +++ b/vendors/DateJS/build/date.js @@ -0,0 +1,4339 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @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 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 (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 (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.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) { + 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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/build/i18n/af-ZA.js b/vendors/DateJS/build/i18n/af-ZA.js new file mode 100644 index 0000000..49d7b25 --- /dev/null +++ b/vendors/DateJS/build/i18n/af-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-AE.js b/vendors/DateJS/build/i18n/ar-AE.js new file mode 100644 index 0000000..23c772c --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-AE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-BH.js b/vendors/DateJS/build/i18n/ar-BH.js new file mode 100644 index 0000000..2a9e4ab --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-BH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-DZ.js b/vendors/DateJS/build/i18n/ar-DZ.js new file mode 100644 index 0000000..b5fefab --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-DZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-EG.js b/vendors/DateJS/build/i18n/ar-EG.js new file mode 100644 index 0000000..bb06d79 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-EG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-IQ.js b/vendors/DateJS/build/i18n/ar-IQ.js new file mode 100644 index 0000000..fbd2e41 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-IQ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-JO.js b/vendors/DateJS/build/i18n/ar-JO.js new file mode 100644 index 0000000..e5b621c --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-JO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-KW.js b/vendors/DateJS/build/i18n/ar-KW.js new file mode 100644 index 0000000..630c44c --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-KW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-LB.js b/vendors/DateJS/build/i18n/ar-LB.js new file mode 100644 index 0000000..ae11658 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-LB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-LY.js b/vendors/DateJS/build/i18n/ar-LY.js new file mode 100644 index 0000000..3964bad --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-LY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-MA.js b/vendors/DateJS/build/i18n/ar-MA.js new file mode 100644 index 0000000..9e22c05 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-MA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-OM.js b/vendors/DateJS/build/i18n/ar-OM.js new file mode 100644 index 0000000..6d76101 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-OM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-QA.js b/vendors/DateJS/build/i18n/ar-QA.js new file mode 100644 index 0000000..89056c5 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-QA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-SA.js b/vendors/DateJS/build/i18n/ar-SA.js new file mode 100644 index 0000000..379b14f --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-SA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-SY.js b/vendors/DateJS/build/i18n/ar-SY.js new file mode 100644 index 0000000..ff34f95 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-SY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-TN.js b/vendors/DateJS/build/i18n/ar-TN.js new file mode 100644 index 0000000..1fff2f0 --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-TN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ar-YE.js b/vendors/DateJS/build/i18n/ar-YE.js new file mode 100644 index 0000000..4607a0f --- /dev/null +++ b/vendors/DateJS/build/i18n/ar-YE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/az-Cyrl-AZ.js b/vendors/DateJS/build/i18n/az-Cyrl-AZ.js new file mode 100644 index 0000000..19a2673 --- /dev/null +++ b/vendors/DateJS/build/i18n/az-Cyrl-AZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/az-Latn-AZ.js b/vendors/DateJS/build/i18n/az-Latn-AZ.js new file mode 100644 index 0000000..7014595 --- /dev/null +++ b/vendors/DateJS/build/i18n/az-Latn-AZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/be-BY.js b/vendors/DateJS/build/i18n/be-BY.js new file mode 100644 index 0000000..072226d --- /dev/null +++ b/vendors/DateJS/build/i18n/be-BY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/bg-BG.js b/vendors/DateJS/build/i18n/bg-BG.js new file mode 100644 index 0000000..1945de9 --- /dev/null +++ b/vendors/DateJS/build/i18n/bg-BG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/bs-Latn-BA.js b/vendors/DateJS/build/i18n/bs-Latn-BA.js new file mode 100644 index 0000000..7b93ecd --- /dev/null +++ b/vendors/DateJS/build/i18n/bs-Latn-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ca-ES.js b/vendors/DateJS/build/i18n/ca-ES.js new file mode 100644 index 0000000..ef13faa --- /dev/null +++ b/vendors/DateJS/build/i18n/ca-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/cs-CZ.js b/vendors/DateJS/build/i18n/cs-CZ.js new file mode 100644 index 0000000..b8a3265 --- /dev/null +++ b/vendors/DateJS/build/i18n/cs-CZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/cy-GB.js b/vendors/DateJS/build/i18n/cy-GB.js new file mode 100644 index 0000000..b8cfb75 --- /dev/null +++ b/vendors/DateJS/build/i18n/cy-GB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/da-DK.js b/vendors/DateJS/build/i18n/da-DK.js new file mode 100644 index 0000000..6216118 --- /dev/null +++ b/vendors/DateJS/build/i18n/da-DK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/de-AT.js b/vendors/DateJS/build/i18n/de-AT.js new file mode 100644 index 0000000..9bb0c5f --- /dev/null +++ b/vendors/DateJS/build/i18n/de-AT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/de-CH.js b/vendors/DateJS/build/i18n/de-CH.js new file mode 100644 index 0000000..92486d1 --- /dev/null +++ b/vendors/DateJS/build/i18n/de-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/de-DE.js b/vendors/DateJS/build/i18n/de-DE.js new file mode 100644 index 0000000..d084715 --- /dev/null +++ b/vendors/DateJS/build/i18n/de-DE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/de-LI.js b/vendors/DateJS/build/i18n/de-LI.js new file mode 100644 index 0000000..a2c9afd --- /dev/null +++ b/vendors/DateJS/build/i18n/de-LI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/de-LU.js b/vendors/DateJS/build/i18n/de-LU.js new file mode 100644 index 0000000..83fe014 --- /dev/null +++ b/vendors/DateJS/build/i18n/de-LU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/dv-MV.js b/vendors/DateJS/build/i18n/dv-MV.js new file mode 100644 index 0000000..de2abfe --- /dev/null +++ b/vendors/DateJS/build/i18n/dv-MV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/el-GR.js b/vendors/DateJS/build/i18n/el-GR.js new file mode 100644 index 0000000..189174c --- /dev/null +++ b/vendors/DateJS/build/i18n/el-GR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-029.js b/vendors/DateJS/build/i18n/en-029.js new file mode 100644 index 0000000..a38d273 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-029.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-AU.js b/vendors/DateJS/build/i18n/en-AU.js new file mode 100644 index 0000000..9a3c38b --- /dev/null +++ b/vendors/DateJS/build/i18n/en-AU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-BZ.js b/vendors/DateJS/build/i18n/en-BZ.js new file mode 100644 index 0000000..488e436 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-BZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-CA.js b/vendors/DateJS/build/i18n/en-CA.js new file mode 100644 index 0000000..952ae45 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-CA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-GB.js b/vendors/DateJS/build/i18n/en-GB.js new file mode 100644 index 0000000..186da92 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-GB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-IE.js b/vendors/DateJS/build/i18n/en-IE.js new file mode 100644 index 0000000..3fdb220 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-IE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-JM.js b/vendors/DateJS/build/i18n/en-JM.js new file mode 100644 index 0000000..5ea1c73 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-JM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-NZ.js b/vendors/DateJS/build/i18n/en-NZ.js new file mode 100644 index 0000000..5dc1d74 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-NZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-PH.js b/vendors/DateJS/build/i18n/en-PH.js new file mode 100644 index 0000000..6877b63 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-PH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-TT.js b/vendors/DateJS/build/i18n/en-TT.js new file mode 100644 index 0000000..c4ab826 --- /dev/null +++ b/vendors/DateJS/build/i18n/en-TT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-ZA.js b/vendors/DateJS/build/i18n/en-ZA.js new file mode 100644 index 0000000..1b928cc --- /dev/null +++ b/vendors/DateJS/build/i18n/en-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/en-ZW.js b/vendors/DateJS/build/i18n/en-ZW.js new file mode 100644 index 0000000..c6d320d --- /dev/null +++ b/vendors/DateJS/build/i18n/en-ZW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-AR.js b/vendors/DateJS/build/i18n/es-AR.js new file mode 100644 index 0000000..32493e0 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-AR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-BO.js b/vendors/DateJS/build/i18n/es-BO.js new file mode 100644 index 0000000..f17f4e8 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-BO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-CL.js b/vendors/DateJS/build/i18n/es-CL.js new file mode 100644 index 0000000..e5e5d9c --- /dev/null +++ b/vendors/DateJS/build/i18n/es-CL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-CO.js b/vendors/DateJS/build/i18n/es-CO.js new file mode 100644 index 0000000..cae5e70 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-CO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-CR.js b/vendors/DateJS/build/i18n/es-CR.js new file mode 100644 index 0000000..87880a6 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-CR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-DO.js b/vendors/DateJS/build/i18n/es-DO.js new file mode 100644 index 0000000..69c56c5 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-DO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-EC.js b/vendors/DateJS/build/i18n/es-EC.js new file mode 100644 index 0000000..2a9d238 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-EC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-ES.js b/vendors/DateJS/build/i18n/es-ES.js new file mode 100644 index 0000000..472f15a --- /dev/null +++ b/vendors/DateJS/build/i18n/es-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-GT.js b/vendors/DateJS/build/i18n/es-GT.js new file mode 100644 index 0000000..3256ec6 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-GT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-HN.js b/vendors/DateJS/build/i18n/es-HN.js new file mode 100644 index 0000000..01570ec --- /dev/null +++ b/vendors/DateJS/build/i18n/es-HN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-MX.js b/vendors/DateJS/build/i18n/es-MX.js new file mode 100644 index 0000000..5df1fe9 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-MX.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-NI.js b/vendors/DateJS/build/i18n/es-NI.js new file mode 100644 index 0000000..565ab6d --- /dev/null +++ b/vendors/DateJS/build/i18n/es-NI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-PA.js b/vendors/DateJS/build/i18n/es-PA.js new file mode 100644 index 0000000..dc1b59c --- /dev/null +++ b/vendors/DateJS/build/i18n/es-PA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-PE.js b/vendors/DateJS/build/i18n/es-PE.js new file mode 100644 index 0000000..5023be8 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-PE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-PR.js b/vendors/DateJS/build/i18n/es-PR.js new file mode 100644 index 0000000..359f882 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-PR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-PY.js b/vendors/DateJS/build/i18n/es-PY.js new file mode 100644 index 0000000..a83dcf0 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-PY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-SV.js b/vendors/DateJS/build/i18n/es-SV.js new file mode 100644 index 0000000..ed437a2 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-SV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-UY.js b/vendors/DateJS/build/i18n/es-UY.js new file mode 100644 index 0000000..736b179 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-UY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/es-VE.js b/vendors/DateJS/build/i18n/es-VE.js new file mode 100644 index 0000000..ff8dc17 --- /dev/null +++ b/vendors/DateJS/build/i18n/es-VE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/et-EE.js b/vendors/DateJS/build/i18n/et-EE.js new file mode 100644 index 0000000..fe130f9 --- /dev/null +++ b/vendors/DateJS/build/i18n/et-EE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/eu-ES.js b/vendors/DateJS/build/i18n/eu-ES.js new file mode 100644 index 0000000..d3cde8a --- /dev/null +++ b/vendors/DateJS/build/i18n/eu-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fa-IR.js b/vendors/DateJS/build/i18n/fa-IR.js new file mode 100644 index 0000000..8198538 --- /dev/null +++ b/vendors/DateJS/build/i18n/fa-IR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fi-FI.js b/vendors/DateJS/build/i18n/fi-FI.js new file mode 100644 index 0000000..12f9a44 --- /dev/null +++ b/vendors/DateJS/build/i18n/fi-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fo-FO.js b/vendors/DateJS/build/i18n/fo-FO.js new file mode 100644 index 0000000..802a20b --- /dev/null +++ b/vendors/DateJS/build/i18n/fo-FO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-BE.js b/vendors/DateJS/build/i18n/fr-BE.js new file mode 100644 index 0000000..8ff63bf --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-BE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-CA.js b/vendors/DateJS/build/i18n/fr-CA.js new file mode 100644 index 0000000..27ce919 --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-CA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-CH.js b/vendors/DateJS/build/i18n/fr-CH.js new file mode 100644 index 0000000..be79585 --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-FR.js b/vendors/DateJS/build/i18n/fr-FR.js new file mode 100644 index 0000000..12366a0 --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-FR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-LU.js b/vendors/DateJS/build/i18n/fr-LU.js new file mode 100644 index 0000000..0ca498d --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-LU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/fr-MC.js b/vendors/DateJS/build/i18n/fr-MC.js new file mode 100644 index 0000000..cd423ce --- /dev/null +++ b/vendors/DateJS/build/i18n/fr-MC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/gl-ES.js b/vendors/DateJS/build/i18n/gl-ES.js new file mode 100644 index 0000000..2873c9e --- /dev/null +++ b/vendors/DateJS/build/i18n/gl-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/gu-IN.js b/vendors/DateJS/build/i18n/gu-IN.js new file mode 100644 index 0000000..8e4e8d5 --- /dev/null +++ b/vendors/DateJS/build/i18n/gu-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/he-IL.js b/vendors/DateJS/build/i18n/he-IL.js new file mode 100644 index 0000000..77fecc0 --- /dev/null +++ b/vendors/DateJS/build/i18n/he-IL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/hi-IN.js b/vendors/DateJS/build/i18n/hi-IN.js new file mode 100644 index 0000000..06185b1 --- /dev/null +++ b/vendors/DateJS/build/i18n/hi-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/hr-BA.js b/vendors/DateJS/build/i18n/hr-BA.js new file mode 100644 index 0000000..9fe88fc --- /dev/null +++ b/vendors/DateJS/build/i18n/hr-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/hr-HR.js b/vendors/DateJS/build/i18n/hr-HR.js new file mode 100644 index 0000000..0f9d816 --- /dev/null +++ b/vendors/DateJS/build/i18n/hr-HR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/hu-HU.js b/vendors/DateJS/build/i18n/hu-HU.js new file mode 100644 index 0000000..265edb6 --- /dev/null +++ b/vendors/DateJS/build/i18n/hu-HU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/hy-AM.js b/vendors/DateJS/build/i18n/hy-AM.js new file mode 100644 index 0000000..42ca6dc --- /dev/null +++ b/vendors/DateJS/build/i18n/hy-AM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/id-ID.js b/vendors/DateJS/build/i18n/id-ID.js new file mode 100644 index 0000000..583d115 --- /dev/null +++ b/vendors/DateJS/build/i18n/id-ID.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/is-IS.js b/vendors/DateJS/build/i18n/is-IS.js new file mode 100644 index 0000000..350e3b3 --- /dev/null +++ b/vendors/DateJS/build/i18n/is-IS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/it-CH.js b/vendors/DateJS/build/i18n/it-CH.js new file mode 100644 index 0000000..e762838 --- /dev/null +++ b/vendors/DateJS/build/i18n/it-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/it-IT.js b/vendors/DateJS/build/i18n/it-IT.js new file mode 100644 index 0000000..82267c6 --- /dev/null +++ b/vendors/DateJS/build/i18n/it-IT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ja-JP.js b/vendors/DateJS/build/i18n/ja-JP.js new file mode 100644 index 0000000..1576ffc --- /dev/null +++ b/vendors/DateJS/build/i18n/ja-JP.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ka-GE.js b/vendors/DateJS/build/i18n/ka-GE.js new file mode 100644 index 0000000..2e1e618 --- /dev/null +++ b/vendors/DateJS/build/i18n/ka-GE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/kk-KZ.js b/vendors/DateJS/build/i18n/kk-KZ.js new file mode 100644 index 0000000..877e098 --- /dev/null +++ b/vendors/DateJS/build/i18n/kk-KZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/kn-IN.js b/vendors/DateJS/build/i18n/kn-IN.js new file mode 100644 index 0000000..7d60e0e --- /dev/null +++ b/vendors/DateJS/build/i18n/kn-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ko-KR.js b/vendors/DateJS/build/i18n/ko-KR.js new file mode 100644 index 0000000..c34ba8d --- /dev/null +++ b/vendors/DateJS/build/i18n/ko-KR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/kok-IN.js b/vendors/DateJS/build/i18n/kok-IN.js new file mode 100644 index 0000000..bdc2b9d --- /dev/null +++ b/vendors/DateJS/build/i18n/kok-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ky-KG.js b/vendors/DateJS/build/i18n/ky-KG.js new file mode 100644 index 0000000..91c7f45 --- /dev/null +++ b/vendors/DateJS/build/i18n/ky-KG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/lt-LT.js b/vendors/DateJS/build/i18n/lt-LT.js new file mode 100644 index 0000000..9b33011 --- /dev/null +++ b/vendors/DateJS/build/i18n/lt-LT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/lv-LV.js b/vendors/DateJS/build/i18n/lv-LV.js new file mode 100644 index 0000000..4e945d1 --- /dev/null +++ b/vendors/DateJS/build/i18n/lv-LV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/mi-NZ.js b/vendors/DateJS/build/i18n/mi-NZ.js new file mode 100644 index 0000000..935ed3b --- /dev/null +++ b/vendors/DateJS/build/i18n/mi-NZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/mk-MK.js b/vendors/DateJS/build/i18n/mk-MK.js new file mode 100644 index 0000000..96b704d --- /dev/null +++ b/vendors/DateJS/build/i18n/mk-MK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/mn-MN.js b/vendors/DateJS/build/i18n/mn-MN.js new file mode 100644 index 0000000..f8f748a --- /dev/null +++ b/vendors/DateJS/build/i18n/mn-MN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/mr-IN.js b/vendors/DateJS/build/i18n/mr-IN.js new file mode 100644 index 0000000..7be3036 --- /dev/null +++ b/vendors/DateJS/build/i18n/mr-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ms-BN.js b/vendors/DateJS/build/i18n/ms-BN.js new file mode 100644 index 0000000..39a7b32 --- /dev/null +++ b/vendors/DateJS/build/i18n/ms-BN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ms-MY.js b/vendors/DateJS/build/i18n/ms-MY.js new file mode 100644 index 0000000..024b81b --- /dev/null +++ b/vendors/DateJS/build/i18n/ms-MY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/mt-MT.js b/vendors/DateJS/build/i18n/mt-MT.js new file mode 100644 index 0000000..ede62ee --- /dev/null +++ b/vendors/DateJS/build/i18n/mt-MT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/nb-NO.js b/vendors/DateJS/build/i18n/nb-NO.js new file mode 100644 index 0000000..90b6182 --- /dev/null +++ b/vendors/DateJS/build/i18n/nb-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/nl-BE.js b/vendors/DateJS/build/i18n/nl-BE.js new file mode 100644 index 0000000..ff90c34 --- /dev/null +++ b/vendors/DateJS/build/i18n/nl-BE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/nl-NL.js b/vendors/DateJS/build/i18n/nl-NL.js new file mode 100644 index 0000000..b3b5d9a --- /dev/null +++ b/vendors/DateJS/build/i18n/nl-NL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/nn-NO.js b/vendors/DateJS/build/i18n/nn-NO.js new file mode 100644 index 0000000..8b75035 --- /dev/null +++ b/vendors/DateJS/build/i18n/nn-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ns-ZA.js b/vendors/DateJS/build/i18n/ns-ZA.js new file mode 100644 index 0000000..520ba05 --- /dev/null +++ b/vendors/DateJS/build/i18n/ns-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/pa-IN.js b/vendors/DateJS/build/i18n/pa-IN.js new file mode 100644 index 0000000..bbf4450 --- /dev/null +++ b/vendors/DateJS/build/i18n/pa-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/pl-PL.js b/vendors/DateJS/build/i18n/pl-PL.js new file mode 100644 index 0000000..72b47f3 --- /dev/null +++ b/vendors/DateJS/build/i18n/pl-PL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/pt-BR.js b/vendors/DateJS/build/i18n/pt-BR.js new file mode 100644 index 0000000..23d47be --- /dev/null +++ b/vendors/DateJS/build/i18n/pt-BR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/pt-PT.js b/vendors/DateJS/build/i18n/pt-PT.js new file mode 100644 index 0000000..e4f740f --- /dev/null +++ b/vendors/DateJS/build/i18n/pt-PT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/quz-BO.js b/vendors/DateJS/build/i18n/quz-BO.js new file mode 100644 index 0000000..059e913 --- /dev/null +++ b/vendors/DateJS/build/i18n/quz-BO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/quz-EC.js b/vendors/DateJS/build/i18n/quz-EC.js new file mode 100644 index 0000000..698fcc2 --- /dev/null +++ b/vendors/DateJS/build/i18n/quz-EC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/quz-PE.js b/vendors/DateJS/build/i18n/quz-PE.js new file mode 100644 index 0000000..5d3c93b --- /dev/null +++ b/vendors/DateJS/build/i18n/quz-PE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ro-RO.js b/vendors/DateJS/build/i18n/ro-RO.js new file mode 100644 index 0000000..7352b15 --- /dev/null +++ b/vendors/DateJS/build/i18n/ro-RO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ru-RU.js b/vendors/DateJS/build/i18n/ru-RU.js new file mode 100644 index 0000000..b28ffdb --- /dev/null +++ b/vendors/DateJS/build/i18n/ru-RU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sa-IN.js b/vendors/DateJS/build/i18n/sa-IN.js new file mode 100644 index 0000000..eba2aa1 --- /dev/null +++ b/vendors/DateJS/build/i18n/sa-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/se-FI.js b/vendors/DateJS/build/i18n/se-FI.js new file mode 100644 index 0000000..ab7bcd6 --- /dev/null +++ b/vendors/DateJS/build/i18n/se-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/se-NO.js b/vendors/DateJS/build/i18n/se-NO.js new file mode 100644 index 0000000..005cb99 --- /dev/null +++ b/vendors/DateJS/build/i18n/se-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/se-SE.js b/vendors/DateJS/build/i18n/se-SE.js new file mode 100644 index 0000000..88e51b3 --- /dev/null +++ b/vendors/DateJS/build/i18n/se-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sk-SK.js b/vendors/DateJS/build/i18n/sk-SK.js new file mode 100644 index 0000000..310f8ad --- /dev/null +++ b/vendors/DateJS/build/i18n/sk-SK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sl-SI.js b/vendors/DateJS/build/i18n/sl-SI.js new file mode 100644 index 0000000..8c388fb --- /dev/null +++ b/vendors/DateJS/build/i18n/sl-SI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sma-NO.js b/vendors/DateJS/build/i18n/sma-NO.js new file mode 100644 index 0000000..31f872a --- /dev/null +++ b/vendors/DateJS/build/i18n/sma-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sma-SE.js b/vendors/DateJS/build/i18n/sma-SE.js new file mode 100644 index 0000000..67f8091 --- /dev/null +++ b/vendors/DateJS/build/i18n/sma-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/smj-NO.js b/vendors/DateJS/build/i18n/smj-NO.js new file mode 100644 index 0000000..6d25dc0 --- /dev/null +++ b/vendors/DateJS/build/i18n/smj-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/smj-SE.js b/vendors/DateJS/build/i18n/smj-SE.js new file mode 100644 index 0000000..a11f322 --- /dev/null +++ b/vendors/DateJS/build/i18n/smj-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/smn-FI.js b/vendors/DateJS/build/i18n/smn-FI.js new file mode 100644 index 0000000..2fde1e5 --- /dev/null +++ b/vendors/DateJS/build/i18n/smn-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sms-FI.js b/vendors/DateJS/build/i18n/sms-FI.js new file mode 100644 index 0000000..ee5b034 --- /dev/null +++ b/vendors/DateJS/build/i18n/sms-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sq-AL.js b/vendors/DateJS/build/i18n/sq-AL.js new file mode 100644 index 0000000..474a331 --- /dev/null +++ b/vendors/DateJS/build/i18n/sq-AL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sr-Cyrl-BA.js b/vendors/DateJS/build/i18n/sr-Cyrl-BA.js new file mode 100644 index 0000000..14eb2a7 --- /dev/null +++ b/vendors/DateJS/build/i18n/sr-Cyrl-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sr-Cyrl-CS.js b/vendors/DateJS/build/i18n/sr-Cyrl-CS.js new file mode 100644 index 0000000..383c58b --- /dev/null +++ b/vendors/DateJS/build/i18n/sr-Cyrl-CS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sr-Latn-BA.js b/vendors/DateJS/build/i18n/sr-Latn-BA.js new file mode 100644 index 0000000..afe178e --- /dev/null +++ b/vendors/DateJS/build/i18n/sr-Latn-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sr-Latn-CS.js b/vendors/DateJS/build/i18n/sr-Latn-CS.js new file mode 100644 index 0000000..03ff833 --- /dev/null +++ b/vendors/DateJS/build/i18n/sr-Latn-CS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sv-FI.js b/vendors/DateJS/build/i18n/sv-FI.js new file mode 100644 index 0000000..c308075 --- /dev/null +++ b/vendors/DateJS/build/i18n/sv-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sv-SE.js b/vendors/DateJS/build/i18n/sv-SE.js new file mode 100644 index 0000000..f51ee50 --- /dev/null +++ b/vendors/DateJS/build/i18n/sv-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/sw-KE.js b/vendors/DateJS/build/i18n/sw-KE.js new file mode 100644 index 0000000..65fcb28 --- /dev/null +++ b/vendors/DateJS/build/i18n/sw-KE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/syr-SY.js b/vendors/DateJS/build/i18n/syr-SY.js new file mode 100644 index 0000000..27c4232 --- /dev/null +++ b/vendors/DateJS/build/i18n/syr-SY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ta-IN.js b/vendors/DateJS/build/i18n/ta-IN.js new file mode 100644 index 0000000..4dd916c --- /dev/null +++ b/vendors/DateJS/build/i18n/ta-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/te-IN.js b/vendors/DateJS/build/i18n/te-IN.js new file mode 100644 index 0000000..00ad7d3 --- /dev/null +++ b/vendors/DateJS/build/i18n/te-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/th-TH.js b/vendors/DateJS/build/i18n/th-TH.js new file mode 100644 index 0000000..c783f3f --- /dev/null +++ b/vendors/DateJS/build/i18n/th-TH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/tn-ZA.js b/vendors/DateJS/build/i18n/tn-ZA.js new file mode 100644 index 0000000..06112fd --- /dev/null +++ b/vendors/DateJS/build/i18n/tn-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/tr-TR.js b/vendors/DateJS/build/i18n/tr-TR.js new file mode 100644 index 0000000..d5c4223 --- /dev/null +++ b/vendors/DateJS/build/i18n/tr-TR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/tt-RU.js b/vendors/DateJS/build/i18n/tt-RU.js new file mode 100644 index 0000000..5e9f4c2 --- /dev/null +++ b/vendors/DateJS/build/i18n/tt-RU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/uk-UA.js b/vendors/DateJS/build/i18n/uk-UA.js new file mode 100644 index 0000000..adb15c1 --- /dev/null +++ b/vendors/DateJS/build/i18n/uk-UA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/ur-PK.js b/vendors/DateJS/build/i18n/ur-PK.js new file mode 100644 index 0000000..1cfdc5c --- /dev/null +++ b/vendors/DateJS/build/i18n/ur-PK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/uz-Cyrl-UZ.js b/vendors/DateJS/build/i18n/uz-Cyrl-UZ.js new file mode 100644 index 0000000..1a1e7a0 --- /dev/null +++ b/vendors/DateJS/build/i18n/uz-Cyrl-UZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/uz-Latn-UZ.js b/vendors/DateJS/build/i18n/uz-Latn-UZ.js new file mode 100644 index 0000000..330b7da --- /dev/null +++ b/vendors/DateJS/build/i18n/uz-Latn-UZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/vi-VN.js b/vendors/DateJS/build/i18n/vi-VN.js new file mode 100644 index 0000000..c63a5f9 --- /dev/null +++ b/vendors/DateJS/build/i18n/vi-VN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/xh-ZA.js b/vendors/DateJS/build/i18n/xh-ZA.js new file mode 100644 index 0000000..46fd37a --- /dev/null +++ b/vendors/DateJS/build/i18n/xh-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zh-CN.js b/vendors/DateJS/build/i18n/zh-CN.js new file mode 100644 index 0000000..54a1f10 --- /dev/null +++ b/vendors/DateJS/build/i18n/zh-CN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zh-HK.js b/vendors/DateJS/build/i18n/zh-HK.js new file mode 100644 index 0000000..1ec1482 --- /dev/null +++ b/vendors/DateJS/build/i18n/zh-HK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zh-MO.js b/vendors/DateJS/build/i18n/zh-MO.js new file mode 100644 index 0000000..6606109 --- /dev/null +++ b/vendors/DateJS/build/i18n/zh-MO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zh-SG.js b/vendors/DateJS/build/i18n/zh-SG.js new file mode 100644 index 0000000..e674dfa --- /dev/null +++ b/vendors/DateJS/build/i18n/zh-SG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zh-TW.js b/vendors/DateJS/build/i18n/zh-TW.js new file mode 100644 index 0000000..29f7811 --- /dev/null +++ b/vendors/DateJS/build/i18n/zh-TW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/i18n/zu-ZA.js b/vendors/DateJS/build/i18n/zu-ZA.js new file mode 100644 index 0000000..25b0f8e --- /dev/null +++ b/vendors/DateJS/build/i18n/zu-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/build/production/date-af-ZA.min.js b/vendors/DateJS/build/production/date-af-ZA.min.js new file mode 100644 index 0000000..e22d964 --- /dev/null +++ b/vendors/DateJS/build/production/date-af-ZA.min.js @@ -0,0 +1,134 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-AE"]={name:"ar-AE",englishName:"Arabic (U.A.E.)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062a \u0627\u0644\u0639\u0631\u0628\u064a\u0629 \u0627\u0644\u0645\u062a\u062d\u062f\u0629)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633", +Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623", +M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631", +November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631",Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631", +Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631",AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631","/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631", +"/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f","/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-BH"]={name:"ar-BH",englishName:"Arabic (Bahrain)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0628\u062d\u0631\u064a\u0646)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-DZ"]={name:"ar-DZ",englishName:"Arabic (Algeria)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u062c\u0632\u0627\u0626\u0631)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u062c\u0627\u0646\u0641\u064a\u064a\u0647",February:"\u0641\u064a\u0641\u0631\u064a\u064a\u0647",March:"\u0645\u0627\u0631\u0633",April:"\u0623\u0641\u0631\u064a\u0644",May:"\u0645\u064a",June:"\u062c\u0648\u0627\u0646",July:"\u062c\u0648\u064a\u064a\u0647",August:"\u0623\u0648\u062a",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u062c\u0627\u0646\u0641\u064a\u064a\u0647",Feb_Abbr:"\u0641\u064a\u0641\u0631\u064a\u064a\u0647",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0623\u0641\u0631\u064a\u0644",May_Abbr:"\u0645\u064a",Jun_Abbr:"\u062c\u0648\u0627\u0646",Jul_Abbr:"\u062c\u0648\u064a\u064a\u0647",Aug_Abbr:"\u0623\u0648\u062a",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u062c\u0627\u0646\u0641\u064a\u064a\u0647","/feb(ruary)?/":"\u0641\u064a\u0641\u0631\u064a\u064a\u0647", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0623\u0641\u0631\u064a\u0644","/may/":"\u0645\u064a","/jun(e)?/":"\u062c\u0648\u0627\u0646","/jul(y)?/":"\u062c\u0648\u064a\u064a\u0647","/aug(ust)?/":"\u0623\u0648\u062a","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-EG"]={name:"ar-EG",englishName:"Arabic (Egypt)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0645\u0635\u0631)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f", +Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c", +S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-IQ"]={name:"ar-IQ",englishName:"Arabic (Iraq)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0639\u0631\u0627\u0642)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",February:"\u0634\u0628\u0627\u0637",March:"\u0622\u0630\u0627\u0631",April:"\u0646\u064a\u0633\u0627\u0646",May:"\u0623\u064a\u0627\u0631",June:"\u062d\u0632\u064a\u0631\u0627\u0646",July:"\u062a\u0645\u0648\u0632",August:"\u0622\u0628",September:"\u0623\u064a\u0644\u0648\u0644",October:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",November:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +December:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",Jan_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Feb_Abbr:"\u0634\u0628\u0627\u0637",Mar_Abbr:"\u0622\u0630\u0627\u0631",Apr_Abbr:"\u0646\u064a\u0633\u0627\u0646",May_Abbr:"\u0623\u064a\u0627\u0631",Jun_Abbr:"\u062d\u0632\u064a\u0631\u0627\u0646",Jul_Abbr:"\u062a\u0645\u0648\u0632",Aug_Abbr:"\u0622\u0628",Sep_Abbr:"\u0623\u064a\u0644\u0648\u0644",Oct_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +Nov_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Dec_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",AM:"\u0635",PM:"\u0645",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)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/feb(ruary)?/":"\u0634\u0628\u0627\u0637","/mar(ch)?/":"\u0622\u0630\u0627\u0631","/apr(il)?/":"\u0646\u064a\u0633\u0627\u0646","/may/":"\u0623\u064a\u0627\u0631","/jun(e)?/":"\u062d\u0632\u064a\u0631\u0627\u0646","/jul(y)?/":"\u062a\u0645\u0648\u0632","/aug(ust)?/":"\u0622\u0628","/sep(t(ember)?)?/":"\u0623\u064a\u0644\u0648\u0644","/oct(ober)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +"/nov(ember)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/dec(ember)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f","/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629", +"/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-JO"]={name:"ar-JO",englishName:"Arabic (Jordan)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0623\u0631\u062f\u0646)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",February:"\u0634\u0628\u0627\u0637",March:"\u0622\u0630\u0627\u0631",April:"\u0646\u064a\u0633\u0627\u0646",May:"\u0623\u064a\u0627\u0631",June:"\u062d\u0632\u064a\u0631\u0627\u0646",July:"\u062a\u0645\u0648\u0632",August:"\u0622\u0628",September:"\u0623\u064a\u0644\u0648\u0644",October:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",November:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +December:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",Jan_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Feb_Abbr:"\u0634\u0628\u0627\u0637",Mar_Abbr:"\u0622\u0630\u0627\u0631",Apr_Abbr:"\u0646\u064a\u0633\u0627\u0646",May_Abbr:"\u0623\u064a\u0627\u0631",Jun_Abbr:"\u062d\u0632\u064a\u0631\u0627\u0646",Jul_Abbr:"\u062a\u0645\u0648\u0632",Aug_Abbr:"\u0622\u0628",Sep_Abbr:"\u0623\u064a\u0644\u0648\u0644",Oct_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +Nov_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Dec_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",AM:"\u0635",PM:"\u0645",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)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/feb(ruary)?/":"\u0634\u0628\u0627\u0637","/mar(ch)?/":"\u0622\u0630\u0627\u0631","/apr(il)?/":"\u0646\u064a\u0633\u0627\u0646","/may/":"\u0623\u064a\u0627\u0631","/jun(e)?/":"\u062d\u0632\u064a\u0631\u0627\u0646","/jul(y)?/":"\u062a\u0645\u0648\u0632","/aug(ust)?/":"\u0622\u0628","/sep(t(ember)?)?/":"\u0623\u064a\u0644\u0648\u0644","/oct(ober)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +"/nov(ember)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/dec(ember)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f","/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629", +"/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-KW"]={name:"ar-KW",englishName:"Arabic (Kuwait)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0643\u0648\u064a\u062a)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-LB"]={name:"ar-LB",englishName:"Arabic (Lebanon)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0644\u0628\u0646\u0627\u0646)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",February:"\u0634\u0628\u0627\u0637",March:"\u0622\u0630\u0627\u0631",April:"\u0646\u064a\u0633\u0627\u0646",May:"\u0623\u064a\u0627\u0631",June:"\u062d\u0632\u064a\u0631\u0627\u0646",July:"\u062a\u0645\u0648\u0632",August:"\u0622\u0628",September:"\u0623\u064a\u0644\u0648\u0644",October:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",November:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +December:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",Jan_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Feb_Abbr:"\u0634\u0628\u0627\u0637",Mar_Abbr:"\u0622\u0630\u0627\u0631",Apr_Abbr:"\u0646\u064a\u0633\u0627\u0646",May_Abbr:"\u0623\u064a\u0627\u0631",Jun_Abbr:"\u062d\u0632\u064a\u0631\u0627\u0646",Jul_Abbr:"\u062a\u0645\u0648\u0632",Aug_Abbr:"\u0622\u0628",Sep_Abbr:"\u0623\u064a\u0644\u0648\u0644",Oct_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +Nov_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Dec_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",AM:"\u0635",PM:"\u0645",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)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/feb(ruary)?/":"\u0634\u0628\u0627\u0637","/mar(ch)?/":"\u0622\u0630\u0627\u0631","/apr(il)?/":"\u0646\u064a\u0633\u0627\u0646","/may/":"\u0623\u064a\u0627\u0631","/jun(e)?/":"\u062d\u0632\u064a\u0631\u0627\u0646","/jul(y)?/":"\u062a\u0645\u0648\u0632","/aug(ust)?/":"\u0622\u0628","/sep(t(ember)?)?/":"\u0623\u064a\u0644\u0648\u0644","/oct(ober)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +"/nov(ember)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/dec(ember)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f","/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629", +"/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-LY"]={name:"ar-LY",englishName:"Arabic (Libya)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0644\u064a\u0628\u064a\u0627)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-MA"]={name:"ar-MA",englishName:"Arabic (Morocco)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0645\u0645\u0644\u0643\u0629 \u0627\u0644\u0645\u063a\u0631\u0628\u064a\u0629)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629", +Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b", +W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648\u0632",August:"\u063a\u0634\u062a",September:"\u0634\u062a\u0646\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0646\u0628\u0631", +December:"\u062f\u062c\u0646\u0628\u0631",Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648\u0632",Aug_Abbr:"\u063a\u0634\u062a",Sep_Abbr:"\u0634\u062a\u0646\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0646\u0628\u0631",Dec_Abbr:"\u062f\u062c\u0646\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648\u0632","/aug(ust)?/":"\u063a\u0634\u062a","/sep(t(ember)?)?/":"\u0634\u062a\u0646\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0646\u0628\u0631","/dec(ember)?/":"\u062f\u062c\u0646\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-OM"]={name:"ar-OM",englishName:"Arabic (Oman)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0645\u0627\u0646)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-QA"]={name:"ar-QA",englishName:"Arabic (Qatar)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0642\u0637\u0631)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f", +Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c", +S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-SA"]={name:"ar-SA",englishName:"Arabic (Saudi Arabia)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0645\u0645\u0644\u0643\u0629 \u0627\u0644\u0639\u0631\u0628\u064a\u0629 \u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633", +Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u062d",Mo:"\u0646",Tu:"\u062b",We:"\u0631",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u062d", +M_Mon_Initial:"\u0646",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0631",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0645\u062d\u0631\u0645",February:"\u0635\u0641\u0631",March:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0623\u0648\u0644",April:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",May:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0623\u0648\u0644\u0649",June:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629", +July:"\u0631\u062c\u0628",August:"\u0634\u0639\u0628\u0627\u0646",September:"\u0631\u0645\u0636\u0627\u0646",October:"\u0634\u0648\u0627\u0644",November:"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629",December:"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629",Jan_Abbr:"\u0645\u062d\u0631\u0645",Feb_Abbr:"\u0635\u0641\u0631",Mar_Abbr:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0627\u0648\u0644",Apr_Abbr:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",May_Abbr:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0627\u0648\u0644\u0649", +Jun_Abbr:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629",Jul_Abbr:"\u0631\u062c\u0628",Aug_Abbr:"\u0634\u0639\u0628\u0627\u0646",Sep_Abbr:"\u0631\u0645\u0636\u0627\u0646",Oct_Abbr:"\u0634\u0648\u0627\u0644",Nov_Abbr:"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629",Dec_Abbr:"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629",AM:"\u0635",PM:"\u0645",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)?/":"\u0645\u062d\u0631\u0645","/feb(ruary)?/":"\u0635\u0641\u0631","/mar(ch)?/":"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0623\u0648\u0644","/apr(il)?/":"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +"/may/":"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0623\u0648\u0644\u0649","/jun(e)?/":"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629","/jul(y)?/":"\u0631\u062c\u0628","/aug(ust)?/":"\u0634\u0639\u0628\u0627\u0646","/sep(t(ember)?)?/":"\u0631\u0645\u0636\u0627\u0646","/oct(ober)?/":"\u0634\u0648\u0627\u0644","/nov(ember)?/":"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629","/dec(ember)?/":"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627\u0644\u0627\u062b\u0646\u064a\u0646","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-SY"]={name:"ar-SY",englishName:"Arabic (Syria)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0633\u0648\u0631\u064a\u0627)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",February:"\u0634\u0628\u0627\u0637",March:"\u0622\u0630\u0627\u0631",April:"\u0646\u064a\u0633\u0627\u0646",May:"\u0623\u064a\u0627\u0631",June:"\u062d\u0632\u064a\u0631\u0627\u0646",July:"\u062a\u0645\u0648\u0632",August:"\u0622\u0628",September:"\u0623\u064a\u0644\u0648\u0644",October:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",November:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +December:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",Jan_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Feb_Abbr:"\u0634\u0628\u0627\u0637",Mar_Abbr:"\u0622\u0630\u0627\u0631",Apr_Abbr:"\u0646\u064a\u0633\u0627\u0646",May_Abbr:"\u0623\u064a\u0627\u0631",Jun_Abbr:"\u062d\u0632\u064a\u0631\u0627\u0646",Jul_Abbr:"\u062a\u0645\u0648\u0632",Aug_Abbr:"\u0622\u0628",Sep_Abbr:"\u0623\u064a\u0644\u0648\u0644",Oct_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +Nov_Abbr:"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",Dec_Abbr:"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644",AM:"\u0635",PM:"\u0645",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)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/feb(ruary)?/":"\u0634\u0628\u0627\u0637","/mar(ch)?/":"\u0622\u0630\u0627\u0631","/apr(il)?/":"\u0646\u064a\u0633\u0627\u0646","/may/":"\u0623\u064a\u0627\u0631","/jun(e)?/":"\u062d\u0632\u064a\u0631\u0627\u0646","/jul(y)?/":"\u062a\u0645\u0648\u0632","/aug(ust)?/":"\u0622\u0628","/sep(t(ember)?)?/":"\u0623\u064a\u0644\u0648\u0644","/oct(ober)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u0623\u0648\u0644", +"/nov(ember)?/":"\u062a\u0634\u0631\u064a\u0646\u00a0\u0627\u0644\u062b\u0627\u0646\u064a","/dec(ember)?/":"\u0643\u0627\u0646\u0648\u0646\u00a0\u0627\u0644\u0623\u0648\u0644","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f","/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629", +"/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-TN"]={name:"ar-TN",englishName:"Arabic (Tunisia)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u062a\u0648\u0646\u0633)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u062c\u0627\u0646\u0641\u064a",February:"\u0641\u064a\u0641\u0631\u064a",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0641\u0631\u064a\u0644",May:"\u0645\u0627\u064a",June:"\u062c\u0648\u0627\u0646",July:"\u062c\u0648\u064a\u0644\u064a\u0629",August:"\u0627\u0648\u062a",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u062c\u0627\u0646\u0641\u064a",Feb_Abbr:"\u0641\u064a\u0641\u0631\u064a",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0641\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a",Jun_Abbr:"\u062c\u0648\u0627\u0646",Jul_Abbr:"\u062c\u0648\u064a\u0644\u064a\u0629",Aug_Abbr:"\u0627\u0648\u062a",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631",AM:"\u0635", +PM:"\u0645",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)?/":"\u062c\u0627\u0646\u0641\u064a","/feb(ruary)?/":"\u0641\u064a\u0641\u0631\u064a", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0641\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a","/jun(e)?/":"\u062c\u0648\u0627\u0646","/jul(y)?/":"\u062c\u0648\u064a\u0644\u064a\u0629","/aug(ust)?/":"\u0627\u0648\u062a","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ar-YE"]={name:"ar-YE",englishName:"Arabic (Yemen)",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u064a\u0645\u0646)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629",Saturday:"\u0627\u0644\u0633\u0628\u062a", +Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u0623",Mo:"\u0627",Tu:"\u062b",We:"\u0623",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u0623",M_Mon_Initial:"\u0627",T_Tue_Initial:"\u062b",W_Wed_Initial:"\u0623",T_Thu_Initial:"\u062e", +F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u064a\u0646\u0627\u064a\u0631",February:"\u0641\u0628\u0631\u0627\u064a\u0631",March:"\u0645\u0627\u0631\u0633",April:"\u0627\u0628\u0631\u064a\u0644",May:"\u0645\u0627\u064a\u0648",June:"\u064a\u0648\u0646\u064a\u0648",July:"\u064a\u0648\u0644\u064a\u0648",August:"\u0627\u063a\u0633\u0637\u0633",September:"\u0633\u0628\u062a\u0645\u0628\u0631",October:"\u0627\u0643\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0641\u0645\u0628\u0631",December:"\u062f\u064a\u0633\u0645\u0628\u0631", +Jan_Abbr:"\u064a\u0646\u0627\u064a\u0631",Feb_Abbr:"\u0641\u0628\u0631\u0627\u064a\u0631",Mar_Abbr:"\u0645\u0627\u0631\u0633",Apr_Abbr:"\u0627\u0628\u0631\u064a\u0644",May_Abbr:"\u0645\u0627\u064a\u0648",Jun_Abbr:"\u064a\u0648\u0646\u064a\u0648",Jul_Abbr:"\u064a\u0648\u0644\u064a\u0648",Aug_Abbr:"\u0627\u063a\u0633\u0637\u0633",Sep_Abbr:"\u0633\u0628\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u0643\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0641\u0645\u0628\u0631",Dec_Abbr:"\u062f\u064a\u0633\u0645\u0628\u0631", +AM:"\u0635",PM:"\u0645",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)?/":"\u064a\u0646\u0627\u064a\u0631","/feb(ruary)?/":"\u0641\u0628\u0631\u0627\u064a\u0631", +"/mar(ch)?/":"\u0645\u0627\u0631\u0633","/apr(il)?/":"\u0627\u0628\u0631\u064a\u0644","/may/":"\u0645\u0627\u064a\u0648","/jun(e)?/":"\u064a\u0648\u0646\u064a\u0648","/jul(y)?/":"\u064a\u0648\u0644\u064a\u0648","/aug(ust)?/":"\u0627\u063a\u0633\u0637\u0633","/sep(t(ember)?)?/":"\u0633\u0628\u062a\u0645\u0628\u0631","/oct(ober)?/":"\u0627\u0643\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0641\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u064a\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627(1)?","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["az-Cyrl-AZ"]={name:"az-Cyrl-AZ",englishName:"Azeri (Cyrillic, Azerbaijan)",nativeName:"\u0410\u0437\u04d9\u0440\u0431\u0430\u0458\u04b9\u0430\u043d (\u0410\u0437\u04d9\u0440\u0431\u0430\u0458\u04b9\u0430\u043d)",Sunday:"\u0411\u0430\u0437\u0430\u0440",Monday:"\u0411\u0430\u0437\u0430\u0440\u00a0\u0435\u0440\u0442\u04d9\u0441\u0438",Tuesday:"\u0427\u04d9\u0440\u0448\u04d9\u043d\u0431\u04d9\u00a0\u0430\u0445\u0448\u0430\u043c\u044b",Wednesday:"\u0427\u04d9\u0440\u0448\u04d9\u043d\u0431\u04d9",Thursday:"\u04b8\u04af\u043c\u04d9\u00a0\u0430\u0445\u0448\u0430\u043c\u044b", +Friday:"\u04b8\u04af\u043c\u04d9",Saturday:"\u0428\u04d9\u043d\u0431\u04d9",Sun:"\u0411",Mon:"\u0411\u0435",Tue:"\u0427\u0430",Wed:"\u0427",Thu:"\u04b8\u0430",Fri:"\u04b8",Sat:"\u0428",Su:"\u0411",Mo:"\u0411\u0435",Tu:"\u0427\u0430",We:"\u0427",Th:"\u04b8\u0430",Fr:"\u04b8",Sa:"\u0428",S_Sun_Initial:"\u0411",M_Mon_Initial:"\u0411",T_Tue_Initial:"\u0427",W_Wed_Initial:"\u0427",T_Thu_Initial:"\u04b8",F_Fri_Initial:"\u04b8",S_Sat_Initial:"\u0428",January:"\u0408\u0430\u043d\u0432\u0430\u0440",February:"\u0424\u0435\u0432\u0440\u0430\u043b", +March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0435\u043b",May:"\u041c\u0430\u0458",June:"\u0418\u0458\u0443\u043d",July:"\u0418\u0458\u0443\u043b",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043d\u0442\u0458\u0430\u0431\u0440",October:"\u041e\u043a\u0442\u0458\u0430\u0431\u0440",November:"\u041d\u043e\u0458\u0430\u0431\u0440",December:"\u0414\u0435\u043a\u0430\u0431\u0440",Jan_Abbr:"\u0408\u0430\u043d",Feb_Abbr:"\u0424\u0435\u0432",Mar_Abbr:"\u041c\u0430\u0440", +Apr_Abbr:"\u0410\u043f\u0440",May_Abbr:"\u041c\u0430\u0458",Jun_Abbr:"\u0418\u0458\u0443\u043d",Jul_Abbr:"\u0418\u0458\u0443\u043b",Aug_Abbr:"\u0410\u0432\u0433",Sep_Abbr:"\u0421\u0435\u043d",Oct_Abbr:"\u041e\u043a\u0442",Nov_Abbr:"\u041d\u043e\u044f",Dec_Abbr:"\u0414\u0435\u043a",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)?/":"\u0458\u0430\u043d(\u0432\u0430\u0440)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0430\u043b)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0435\u043b)?","/may/":"\u043c\u0430\u0458","/jun(e)?/":"\u0438\u0458\u0443\u043d","/jul(y)?/":"\u0438\u0458\u0443\u043b","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?", +"/sep(t(ember)?)?/":"\u0441\u0435\u043d(\u0442\u0458\u0430\u0431\u0440)?","/oct(ober)?/":"\u043e\u043a\u0442(\u0458\u0430\u0431\u0440)?","/nov(ember)?/":"\u043d\u043e\u0458\u0430\u0431\u0440","/dec(ember)?/":"\u0434\u0435\u043a(\u0430\u0431\u0440)?","/^su(n(day)?)?/":"^\u0431\u0430\u0437\u0430\u0440","/^mo(n(day)?)?/":"^\u0431\u0430\u0437\u0430\u0440\u00a0\u0435\u0440\u0442\u04d9\u0441\u0438","/^tu(e(s(day)?)?)?/":"^\u0447\u04d9\u0440\u0448\u04d9\u043d\u0431\u04d9\u00a0\u0430\u0445\u0448\u0430\u043c\u044b", +"/^we(d(nesday)?)?/":"^\u0447\u04d9\u0440\u0448\u04d9\u043d\u0431\u04d9","/^th(u(r(s(day)?)?)?)?/":"^\u04b9\u04af\u043c\u04d9\u00a0\u0430\u0445\u0448\u0430\u043c\u044b","/^fr(i(day)?)?/":"^\u04b9\u04af\u043c\u04d9","/^sa(t(urday)?)?/":"^\u0448\u04d9\u043d\u0431\u04d9","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["az-Latn-AZ"]={name:"az-Latn-AZ",englishName:"Azeri (Latin, Azerbaijan)",nativeName:"Az\u0259rbaycan\u00ad\u0131l\u0131 (Az\u0259rbaycanca)",Sunday:"Bazar",Monday:"Bazar\u00a0ert\u0259si",Tuesday:"\u00c7\u0259r\u015f\u0259nb\u0259\u00a0ax\u015fam\u0131",Wednesday:"\u00c7\u0259r\u015f\u0259nb\u0259",Thursday:"C\u00fcm\u0259\u00a0ax\u015fam\u0131",Friday:"C\u00fcm\u0259",Saturday:"\u015e\u0259nb\u0259",Sun:"B",Mon:"Be",Tue:"\u00c7a",Wed:"\u00c7",Thu:"Ca",Fri:"C",Sat:"\u015e",Su:"B", +Mo:"Be",Tu:"\u00c7a",We:"\u00c7",Th:"Ca",Fr:"C",Sa:"\u015e",S_Sun_Initial:"B",M_Mon_Initial:"B",T_Tue_Initial:"\u00c7",W_Wed_Initial:"\u00c7",T_Thu_Initial:"C",F_Fri_Initial:"C",S_Sat_Initial:"\u015e",January:"Yanvar",February:"Fevral",March:"Mart",April:"Aprel",May:"May",June:"\u0130yun",July:"\u0130yul",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:"\u0130yun",Jul_Abbr:"\u0130yul", +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\u00a0ert\u0259si","/^tu(e(s(day)?)?)?/":"^\u00e7\u0259r\u015f\u0259nb\u0259\u00a0ax\u015fam\u0131","/^we(d(nesday)?)?/":"^\u00e7\u0259r\u015f\u0259nb\u0259","/^th(u(r(s(day)?)?)?)?/":"^c\u00fcm\u0259\u00a0ax\u015fam\u0131", +"/^fr(i(day)?)?/":"^c\u00fcm\u0259","/^sa(t(urday)?)?/":"^\u015f\u0259nb\u0259","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?", +"/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST", +NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["be-BY"]={name:"be-BY",englishName:"Belarusian (Belarus)",nativeName:"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0456 (\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u044c)",Sunday:"\u043d\u044f\u0434\u0437\u0435\u043b\u044f",Monday:"\u043f\u0430\u043d\u044f\u0434\u0437\u0435\u043b\u0430\u043a",Tuesday:"\u0430\u045e\u0442\u043e\u0440\u0430\u043a",Wednesday:"\u0441\u0435\u0440\u0430\u0434\u0430",Thursday:"\u0447\u0430\u0446\u0432\u0435\u0440",Friday:"\u043f\u044f\u0442\u043d\u0456\u0446\u0430", +Saturday:"\u0441\u0443\u0431\u043e\u0442\u0430",Sun:"\u043d\u0434",Mon:"\u043f\u043d",Tue:"\u0430\u045e",Wed:"\u0441\u0440",Thu:"\u0447\u0446",Fri:"\u043f\u0442",Sat:"\u0441\u0431",Su:"\u043d\u0434",Mo:"\u043f\u043d",Tu:"\u0430\u045e",We:"\u0441\u0440",Th:"\u0447\u0446",Fr:"\u043f\u0442",Sa:"\u0441\u0431",S_Sun_Initial:"\u043d",M_Mon_Initial:"\u043f",T_Tue_Initial:"\u0430",W_Wed_Initial:"\u0441",T_Thu_Initial:"\u0447",F_Fri_Initial:"\u043f",S_Sat_Initial:"\u0441",January:"\u0421\u0442\u0443\u0434\u0437\u0435\u043d\u044c", +February:"\u041b\u044e\u0442\u044b",March:"\u0421\u0430\u043a\u0430\u0432\u0456\u043a",April:"\u041a\u0440\u0430\u0441\u0430\u0432\u0456\u043a",May:"\u041c\u0430\u0439",June:"\u0427\u044d\u0440\u0432\u0435\u043d\u044c",July:"\u041b\u0456\u043f\u0435\u043d\u044c",August:"\u0416\u043d\u0456\u0432\u0435\u043d\u044c",September:"\u0412\u0435\u0440\u0430\u0441\u0435\u043d\u044c",October:"\u041a\u0430\u0441\u0442\u0440\u044b\u0447\u043d\u0456\u043a",November:"\u041b\u0456\u0441\u0442\u0430\u043f\u0430\u0434", +December:"\u0421\u043d\u0435\u0436\u0430\u043d\u044c",Jan_Abbr:"\u0421\u0442\u0443",Feb_Abbr:"\u041b\u044e\u0442",Mar_Abbr:"\u0421\u0430\u043a",Apr_Abbr:"\u041a\u0440\u0430",May_Abbr:"\u041c\u0430\u0439",Jun_Abbr:"\u0427\u044d\u0440",Jul_Abbr:"\u041b\u0456\u043f",Aug_Abbr:"\u0416\u043d\u0456",Sep_Abbr:"\u0412\u0435\u0440",Oct_Abbr:"\u041a\u0430\u0441",Nov_Abbr:"\u041b\u0456\u0441",Dec_Abbr:"\u0421\u043d\u0435",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)?/":"\u0441\u0442\u0443(\u0434\u0437\u0435\u043d\u044c)?","/feb(ruary)?/":"\u043b\u044e\u0442(\u044b)?","/mar(ch)?/":"\u0441\u0430\u043a(\u0430\u0432\u0456\u043a)?","/apr(il)?/":"\u043a\u0440\u0430(\u0441\u0430\u0432\u0456\u043a)?", +"/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u0447\u044d\u0440(\u0432\u0435\u043d\u044c)?","/jul(y)?/":"\u043b\u0456\u043f(\u0435\u043d\u044c)?","/aug(ust)?/":"\u0436\u043d\u0456(\u0432\u0435\u043d\u044c)?","/sep(t(ember)?)?/":"\u0432\u0435\u0440(\u0430\u0441\u0435\u043d\u044c)?","/oct(ober)?/":"\u043a\u0430\u0441(\u0442\u0440\u044b\u0447\u043d\u0456\u043a)?","/nov(ember)?/":"\u043b\u0456\u0441(\u0442\u0430\u043f\u0430\u0434)?","/dec(ember)?/":"\u0441\u043d\u0435(\u0436\u0430\u043d\u044c)?","/^su(n(day)?)?/":"^\u043d\u044f\u0434\u0437\u0435\u043b\u044f", +"/^mo(n(day)?)?/":"^\u043f\u0430\u043d\u044f\u0434\u0437\u0435\u043b\u0430\u043a","/^tu(e(s(day)?)?)?/":"^\u0430\u045e\u0442\u043e\u0440\u0430\u043a","/^we(d(nesday)?)?/":"^\u0441\u0435\u0440\u0430\u0434\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0430\u0446\u0432\u0435\u0440","/^fr(i(day)?)?/":"^\u043f\u044f\u0442\u043d\u0456\u0446\u0430","/^sa(t(urday)?)?/":"^\u0441\u0443\u0431\u043e\u0442\u0430","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["bg-BG"]={name:"bg-BG",englishName:"Bulgarian (Bulgaria)",nativeName:"\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438 (\u0411\u044a\u043b\u0433\u0430\u0440\u0438\u044f)",Sunday:"\u043d\u0435\u0434\u0435\u043b\u044f",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u043d\u0438\u043a",Tuesday:"\u0432\u0442\u043e\u0440\u043d\u0438\u043a",Wednesday:"\u0441\u0440\u044f\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u044a\u0440\u0442\u044a\u043a",Friday:"\u043f\u0435\u0442\u044a\u043a", +Saturday:"\u0441\u044a\u0431\u043e\u0442\u0430",Sun:"\u041d\u0434",Mon:"\u041f\u043d",Tue:"\u0412\u0442",Wed:"\u0421\u0440",Thu:"\u0427\u0442",Fri:"\u041f\u0442",Sat:"\u0421\u0431",Su:"\u043d\u0435",Mo:"\u043f\u043e",Tu:"\u0432\u0442",We:"\u0441\u0440",Th:"\u0447\u0435",Fr:"\u043f\u0435",Sa:"\u0441\u044a",S_Sun_Initial:"\u043d",M_Mon_Initial:"\u043f",T_Tue_Initial:"\u0432",W_Wed_Initial:"\u0441",T_Thu_Initial:"\u0447",F_Fri_Initial:"\u043f",S_Sat_Initial:"\u0441",January:"\u042f\u043d\u0443\u0430\u0440\u0438", +February:"\u0424\u0435\u0432\u0440\u0443\u0430\u0440\u0438",March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0438\u043b",May:"\u041c\u0430\u0439",June:"\u042e\u043d\u0438",July:"\u042e\u043b\u0438",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438",October:"\u041e\u043a\u0442\u043e\u043c\u0432\u0440\u0438",November:"\u041d\u043e\u0435\u043c\u0432\u0440\u0438",December:"\u0414\u0435\u043a\u0435\u043c\u0432\u0440\u0438",Jan_Abbr:"\u042f\u043d\u0443\u0430\u0440\u0438", +Feb_Abbr:"\u0424\u0435\u0432\u0440\u0443\u0430\u0440\u0438",Mar_Abbr:"\u041c\u0430\u0440\u0442",Apr_Abbr:"\u0410\u043f\u0440\u0438\u043b",May_Abbr:"\u041c\u0430\u0439",Jun_Abbr:"\u042e\u043d\u0438",Jul_Abbr:"\u042e\u043b\u0438",Aug_Abbr:"\u0410\u0432\u0433\u0443\u0441\u0442",Sep_Abbr:"\u0421\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438",Oct_Abbr:"\u041e\u043a\u0442\u043e\u043c\u0432\u0440\u0438",Nov_Abbr:"\u041d\u043e\u0435\u043c\u0432\u0440\u0438",Dec_Abbr:"\u0414\u0435\u043a\u0435\u043c\u0432\u0440\u0438", +AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.M.yyyy '\u0433.'","dddd, MMMM dd, yyyy":"dd MMMM yyyy '\u0433.'","h:mm tt":"HH:mm","h:mm:ss tt":"HH:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"dd MMMM yyyy '\u0433.' 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 '\u0433.'","/jan(uary)?/":"\u044f\u043d\u0443\u0430\u0440\u0438", +"/feb(ruary)?/":"\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438","/mar(ch)?/":"\u043c\u0430\u0440\u0442","/apr(il)?/":"\u0430\u043f\u0440\u0438\u043b","/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u044e\u043d\u0438","/jul(y)?/":"\u044e\u043b\u0438","/aug(ust)?/":"\u0430\u0432\u0433\u0443\u0441\u0442","/sep(t(ember)?)?/":"\u0441\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438","/oct(ober)?/":"\u043e\u043a\u0442\u043e\u043c\u0432\u0440\u0438","/nov(ember)?/":"\u043d\u043e\u0435\u043c\u0432\u0440\u0438", +"/dec(ember)?/":"\u0434\u0435\u043a\u0435\u043c\u0432\u0440\u0438","/^su(n(day)?)?/":"^\u043d\u0435((\u0434\u0435\u043b\u044f)?)?","/^mo(n(day)?)?/":"^\u043f\u043e((\u043d\u0435\u0434\u0435\u043b\u043d\u0438\u043a)?)?","/^tu(e(s(day)?)?)?/":"^\u0432\u0442\u043e\u0440\u043d\u0438\u043a","/^we(d(nesday)?)?/":"^\u0441\u0440\u044f\u0434\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435((\u0442\u0432\u044a\u0440\u0442\u044a\u043a)?)?","/^fr(i(day)?)?/":"^\u043f\u0435((\u0442\u044a\u043a)?)?","/^sa(t(urday)?)?/":"^\u0441\u044a((\u0431\u043e\u0442\u0430)?)?", +"/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?", +"/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST", +CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detvrtak",Friday:"petak",Saturday:"subota",Sun:"ned",Mon:"pon",Tue:"uto",Wed:"sri",Thu:"\u010det",Fri:"pet",Sat:"sub",Su:"ned",Mo:"pon",Tu:"uto",We:"sri",Th:"\u010det",Fr:"pet",Sa:"sub",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u010d", +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)?)?)?)?/":"^\u010detvrtak","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ca-ES"]={name:"ca-ES",englishName:"Catalan (Catalan)",nativeName:"catal\u00e0 (catal\u00e0)",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\u00e7",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\u00e7",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\u00e7","/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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["cs-CZ"]={name:"cs-CZ",englishName:"Czech (Czech Republic)",nativeName:"\u010de\u0161tina (\u010cesk\u00e1\u00a0republika)",Sunday:"ned\u011ble",Monday:"pond\u011bl\u00ed",Tuesday:"\u00fater\u00fd",Wednesday:"st\u0159eda",Thursday:"\u010dtvrtek",Friday:"p\u00e1tek",Saturday:"sobota",Sun:"ne",Mon:"po",Tue:"\u00fat",Wed:"st",Thu:"\u010dt",Fri:"p\u00e1",Sat:"so",Su:"ne",Mo:"po",Tu:"\u00fat",We:"st",Th:"\u010dt",Fr:"p\u00e1",Sa:"so",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"\u00fa", +W_Wed_Initial:"s",T_Thu_Initial:"\u010d",F_Fri_Initial:"p",S_Sat_Initial:"s",January:"leden",February:"\u00fanor",March:"b\u0159ezen",April:"duben",May:"kv\u011bten",June:"\u010derven",July:"\u010dervenec",August:"srpen",September:"z\u00e1\u0159\u00ed",October:"\u0159\u00edjen",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)?/":"\u00fanor","/mar(ch)?/":"b\u0159ezen","/apr(il)?/":"duben","/may/":"kv\u011bten", +"/jun(e)?/":"\u010derven","/jul(y)?/":"\u010dervenec","/aug(ust)?/":"srpen","/sep(t(ember)?)?/":"z\u00e1\u0159\u00ed","/oct(ober)?/":"\u0159\u00edjen","/nov(ember)?/":"listopad","/dec(ember)?/":"prosinec","/^su(n(day)?)?/":"^ned\u011ble","/^mo(n(day)?)?/":"^pond\u011bl\u00ed","/^tu(e(s(day)?)?)?/":"^\u00fater\u00fd","/^we(d(nesday)?)?/":"^st\u0159eda","/^th(u(r(s(day)?)?)?)?/":"^\u010dtvrtek","/^fr(i(day)?)?/":"^p\u00e1tek","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["da-DK"]={name:"da-DK",englishName:"Danish (Denmark)",nativeName:"dansk (Danmark)",Sunday:"s\u00f8ndag",Monday:"mandag",Tuesday:"tirsdag",Wednesday:"onsdag",Thursday:"torsdag",Friday:"fredag",Saturday:"l\u00f8rdag",Sun:"s\u00f8",Mon:"ma",Tue:"ti",Wed:"on",Thu:"to",Fri:"fr",Sat:"l\u00f8",Su:"s\u00f8",Mo:"ma",Tu:"ti",We:"on",Th:"to",Fr:"fr",Sa:"l\u00f8",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\u00f8ndag","/^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\u00f8rdag","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["de-AT"]={name:"de-AT",englishName:"German (Austria)",nativeName:"Deutsch (\u00d6sterreich)",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\u00e4nner", +February:"Februar",March:"M\u00e4rz",April:"April",May:"Mai",June:"Juni",July:"Juli",August:"August",September:"September",October:"Oktober",November:"November",December:"Dezember",Jan_Abbr:"J(\u00e4|a)n",Feb_Abbr:"Feb",Mar_Abbr:"(M(a|\u00e4)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\u00e4n(ner)?","/feb(ruary)?/":"feb(ruar)?","/mar(ch)?/":"m\u00e4r(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\u00e4chste(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\u00fcher)", +"/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e4rz",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\u00e4rz","/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\u00e4chste(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\u00fcher)", +"/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e4rz",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\u00e4rz","/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\u00e4chste(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\u00fcher)", +"/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e4rz",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\u00e4rz","/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\u00e4chste(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\u00fcher)", +"/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e4rz",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\u00e4rz","/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\u00e4chste(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\u00fcher)", +"/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["dv-MV"]={name:"dv-MV",englishName:"Divehi (Maldives)",nativeName:"\u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0 (\u078b\u07a8\u0788\u07ac\u0780\u07a8 \u0783\u07a7\u0787\u07b0\u0796\u07ac)",Sunday:"\u0627\u0644\u0627\u062d\u062f",Monday:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tuesday:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wednesday:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thursday:"\u0627\u0644\u062e\u0645\u064a\u0633",Friday:"\u0627\u0644\u062c\u0645\u0639\u0629", +Saturday:"\u0627\u0644\u0633\u0628\u062a",Sun:"\u0627\u0644\u0627\u062d\u062f",Mon:"\u0627\u0644\u0627\u062b\u0646\u064a\u0646",Tue:"\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621",Wed:"\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621",Thu:"\u0627\u0644\u062e\u0645\u064a\u0633",Fri:"\u0627\u0644\u062c\u0645\u0639\u0629",Sat:"\u0627\u0644\u0633\u0628\u062a",Su:"\u062d",Mo:"\u0646",Tu:"\u062b",We:"\u0631",Th:"\u062e",Fr:"\u062c",Sa:"\u0633",S_Sun_Initial:"\u062d",M_Mon_Initial:"\u0646",T_Tue_Initial:"\u062b", +W_Wed_Initial:"\u0631",T_Thu_Initial:"\u062e",F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0633",January:"\u0645\u062d\u0631\u0645",February:"\u0635\u0641\u0631",March:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0623\u0648\u0644",April:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",May:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0623\u0648\u0644\u0649",June:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629",July:"\u0631\u062c\u0628",August:"\u0634\u0639\u0628\u0627\u0646", +September:"\u0631\u0645\u0636\u0627\u0646",October:"\u0634\u0648\u0627\u0644",November:"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629",December:"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629",Jan_Abbr:"\u0645\u062d\u0631\u0645",Feb_Abbr:"\u0635\u0641\u0631",Mar_Abbr:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0627\u0648\u0644",Apr_Abbr:"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a",May_Abbr:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0627\u0648\u0644\u0649", +Jun_Abbr:"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629",Jul_Abbr:"\u0631\u062c\u0628",Aug_Abbr:"\u0634\u0639\u0628\u0627\u0646",Sep_Abbr:"\u0631\u0645\u0636\u0627\u0646",Oct_Abbr:"\u0634\u0648\u0627\u0644",Nov_Abbr:"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629",Dec_Abbr:"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629",AM:"\u0789\u0786",PM:"\u0789\u078a",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)?/":"\u0645\u062d\u0631\u0645","/feb(ruary)?/":"\u0635\u0641\u0631","/mar(ch)?/":"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u0623\u0648\u0644","/apr(il)?/":"\u0631\u0628\u064a\u0639\u00a0\u0627\u0644\u062b\u0627\u0646\u064a", +"/may/":"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u0623\u0648\u0644\u0649","/jun(e)?/":"\u062c\u0645\u0627\u062f\u0649\u00a0\u0627\u0644\u062b\u0627\u0646\u064a\u0629","/jul(y)?/":"\u0631\u062c\u0628","/aug(ust)?/":"\u0634\u0639\u0628\u0627\u0646","/sep(t(ember)?)?/":"\u0631\u0645\u0636\u0627\u0646","/oct(ober)?/":"\u0634\u0648\u0627\u0644","/nov(ember)?/":"\u0630\u0648\u00a0\u0627\u0644\u0642\u0639\u062f\u0629","/dec(ember)?/":"\u0630\u0648\u00a0\u0627\u0644\u062d\u062c\u0629","/^su(n(day)?)?/":"^\u0627\u0644\u0627\u062d\u062f", +"/^mo(n(day)?)?/":"^\u0627\u0644\u0627\u062b\u0646\u064a\u0646","/^tu(e(s(day)?)?)?/":"^\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621","/^we(d(nesday)?)?/":"^\u0627\u0644\u0627\u0631\u0628\u0639\u0627\u0621","/^th(u(r(s(day)?)?)?)?/":"^\u0627\u0644\u062e\u0645\u064a\u0633","/^fr(i(day)?)?/":"^\u0627\u0644\u062c\u0645\u0639\u0629","/^sa(t(urday)?)?/":"^\u0627\u0644\u0633\u0628\u062a","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["el-GR"]={name:"el-GR",englishName:"Greek (Greece)",nativeName:"\u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac (\u0395\u03bb\u03bb\u03ac\u03b4\u03b1)",Sunday:"\u039a\u03c5\u03c1\u03b9\u03b1\u03ba\u03ae",Monday:"\u0394\u03b5\u03c5\u03c4\u03ad\u03c1\u03b1",Tuesday:"\u03a4\u03c1\u03af\u03c4\u03b7",Wednesday:"\u03a4\u03b5\u03c4\u03ac\u03c1\u03c4\u03b7",Thursday:"\u03a0\u03ad\u03bc\u03c0\u03c4\u03b7",Friday:"\u03a0\u03b1\u03c1\u03b1\u03c3\u03ba\u03b5\u03c5\u03ae",Saturday:"\u03a3\u03ac\u03b2\u03b2\u03b1\u03c4\u03bf", +Sun:"\u039a\u03c5\u03c1",Mon:"\u0394\u03b5\u03c5",Tue:"\u03a4\u03c1\u03b9",Wed:"\u03a4\u03b5\u03c4",Thu:"\u03a0\u03b5\u03bc",Fri:"\u03a0\u03b1\u03c1",Sat:"\u03a3\u03b1\u03b2",Su:"\u039a\u03c5",Mo:"\u0394\u03b5",Tu:"\u03a4\u03c1",We:"\u03a4\u03b5",Th:"\u03a0\u03b5",Fr:"\u03a0\u03b1",Sa:"\u03a3\u03ac",S_Sun_Initial:"\u039a",M_Mon_Initial:"\u0394",T_Tue_Initial:"\u03a4",W_Wed_Initial:"\u03a4",T_Thu_Initial:"\u03a0",F_Fri_Initial:"\u03a0",S_Sat_Initial:"\u03a3",January:"\u0399\u03b1\u03bd\u03bf\u03c5\u03ac\u03c1\u03b9\u03bf\u03c2", +February:"\u03a6\u03b5\u03b2\u03c1\u03bf\u03c5\u03ac\u03c1\u03b9\u03bf\u03c2",March:"\u039c\u03ac\u03c1\u03c4\u03b9\u03bf\u03c2",April:"\u0391\u03c0\u03c1\u03af\u03bb\u03b9\u03bf\u03c2",May:"\u039c\u03ac\u03b9\u03bf\u03c2",June:"\u0399\u03bf\u03cd\u03bd\u03b9\u03bf\u03c2",July:"\u0399\u03bf\u03cd\u03bb\u03b9\u03bf\u03c2",August:"\u0391\u03cd\u03b3\u03bf\u03c5\u03c3\u03c4\u03bf\u03c2",September:"\u03a3\u03b5\u03c0\u03c4\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2",October:"\u039f\u03ba\u03c4\u03ce\u03b2\u03c1\u03b9\u03bf\u03c2", +November:"\u039d\u03bf\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2",December:"\u0394\u03b5\u03ba\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2",Jan_Abbr:"\u0399\u03b1\u03bd",Feb_Abbr:"\u03a6\u03b5\u03b2",Mar_Abbr:"\u039c\u03b1\u03c1",Apr_Abbr:"\u0391\u03c0\u03c1",May_Abbr:"\u039c\u03b1\u03ca",Jun_Abbr:"\u0399\u03bf\u03c5\u03bd",Jul_Abbr:"\u0399\u03bf\u03c5\u03bb",Aug_Abbr:"\u0391\u03c5\u03b3",Sep_Abbr:"\u03a3\u03b5\u03c0",Oct_Abbr:"\u039f\u03ba\u03c4",Nov_Abbr:"\u039d\u03bf\u03b5",Dec_Abbr:"\u0394\u03b5\u03ba", +AM:"\u03c0\u03bc",PM:"\u03bc\u03bc",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)?/":"\u03b9\u03b1\u03bd(\u03bf\u03c5\u03ac\u03c1\u03b9\u03bf\u03c2)?", +"/feb(ruary)?/":"\u03c6\u03b5\u03b2(\u03c1\u03bf\u03c5\u03ac\u03c1\u03b9\u03bf\u03c2)?","/mar(ch)?/":"\u03bc\u03ac\u03c1\u03c4\u03b9\u03bf\u03c2","/apr(il)?/":"\u03b1\u03c0\u03c1(\u03af\u03bb\u03b9\u03bf\u03c2)?","/may/":"\u03bc\u03ac\u03b9\u03bf\u03c2","/jun(e)?/":"\u03b9\u03bf\u03cd\u03bd\u03b9\u03bf\u03c2","/jul(y)?/":"\u03b9\u03bf\u03cd\u03bb\u03b9\u03bf\u03c2","/aug(ust)?/":"\u03b1\u03cd\u03b3\u03bf\u03c5\u03c3\u03c4\u03bf\u03c2","/sep(t(ember)?)?/":"\u03c3\u03b5\u03c0(\u03c4\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2)?", +"/oct(ober)?/":"\u03bf\u03ba\u03c4(\u03ce\u03b2\u03c1\u03b9\u03bf\u03c2)?","/nov(ember)?/":"\u03bd\u03bf\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2","/dec(ember)?/":"\u03b4\u03b5\u03ba(\u03ad\u03bc\u03b2\u03c1\u03b9\u03bf\u03c2)?","/^su(n(day)?)?/":"^\u03ba\u03c5(\u03c1(\u03b9\u03b1\u03ba\u03ae)?)?","/^mo(n(day)?)?/":"^\u03b4\u03b5(\u03c5(\u03c4\u03ad\u03c1\u03b1)?)?","/^tu(e(s(day)?)?)?/":"^\u03c4\u03c1(\u03b9(\u03c4\u03b7)?)?","/^we(d(nesday)?)?/":"^\u03c4\u03b5(\u03c4(\u03ac\u03c1\u03c4\u03b7)?)?", +"/^th(u(r(s(day)?)?)?)?/":"^\u03c0\u03b5(\u03bc(\u03c0\u03c4\u03b7)?)?","/^fr(i(day)?)?/":"^\u03c0\u03b1(\u03c1(\u03b1\u03c3\u03ba\u03b5\u03c5\u03ae)?)?","/^sa(t(urday)?)?/":"^\u03c3\u03ac(\u03b2(\u03b2\u03b1\u03c4\u03bf)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?", +"/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var f=Date,g=Date.CultureStrings?Date.CultureStrings.lang:null,c={},a=function(a,e){var b,h,f,m=e?e:g;if(Date.CultureStrings&&Date.CultureStrings[m]&&Date.CultureStrings[m][a])b=Date.CultureStrings[m][a];else switch(a){case "name":b="en-US";break;case "englishName":b="English (United States)";break;case "nativeName":b="English (United States)";break;case "twoDigitYearMax":b=2049;break;case "firstDayOfWeek":b=0;break;default:if(b=a,h=a.split("_"),f=h.length,1b?1:0;throw new TypeError(a+" - "+b);};f.equals=function(a,b){return 0===a.compareTo(b)};f.getDayName=function(a){return Date.CultureInfo.dayNames[a]};f.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,d=Date.CultureInfo.abbreviatedDayNames,c=Date.CultureInfo.shortestDayNames; +a=a.toLowerCase();for(var h=0;h=a.getTime()&&this.getTime()<=b.getTime()};g.isAfter=function(a){return 1===this.compareTo(a||new Date)};g.isBefore=function(a){return-1===this.compareTo(a||new Date)};g.isToday=g.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};g.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};g.addSeconds=function(a){return a?this.addMilliseconds(1E3*a): +this};g.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};g.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};g.addDays=function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};g.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),d=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5d?!1:!0};f.validateMillisecond=function(e){return a(e,0,999,"millisecond")};f.validateSecond=function(e){return a(e,0,59,"second")};f.validateMinute=function(e){return a(e,0,59,"minute")};f.validateHour=function(e){return a(e,0,23,"hour")};f.validateDay=function(e,b,d){return a(e,1,f.getDaysInMonth(b,d),"day")};f.validateWeek=function(e){return a(e,0,53,"week")}; +f.validateMonth=function(e){return a(e,0,11,"month")};f.validateYear=function(e){return a(e,-271822,275760,"year")};g.set=function(a){f.validateMillisecond(a.millisecond)&&this.addMilliseconds(a.millisecond-this.getMilliseconds());f.validateSecond(a.second)&&this.addSeconds(a.second-this.getSeconds());f.validateMinute(a.minute)&&this.addMinutes(a.minute-this.getMinutes());f.validateHour(a.hour)&&this.addHours(a.hour-this.getHours());f.validateMonth(a.month)&&this.addMonths(a.month-this.getMonth()); +f.validateYear(a.year)&&this.addYears(a.year-this.getFullYear());f.validateDay(a.day,this.getFullYear(),this.getMonth())&&this.addDays(a.day-this.getDate());a.timezone&&this.setTimezone(a.timezone);a.timezoneOffset&&this.setTimezoneOffset(a.timezoneOffset);a.week&&f.validateWeek(a.week)&&this.setWeek(a.week);return this};g.moveToFirstDayOfMonth=function(){return this.set({day:1})};g.moveToLastDayOfMonth=function(){return this.set({day:f.getDaysInMonth(this.getFullYear(),this.getMonth())})};g.moveToNthOccurrence= +function(a,b){if("Weekday"===a){if(0b)this.moveToLastDayOfMonth(),this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var d=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+ +a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};g.getElapsed=function(a){return(a||new Date)-this};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}};g.toString=function(a,f){var d=this;if(!f&&a&&1===a.length){var g,h=Date.CultureInfo.formatPatterns;d.t=d.toString;switch(a){case "d":return d.t(h.shortDate);case "D":return d.t(h.longDate);case "F":return d.t(h.fullDateTime);case "m":return d.t(h.monthDay); +case "r":case "R":return g=d.clone().addMinutes(d.getTimezoneOffset()),g.toString(h.rfc1123)+" GMT";case "s":return d.t(h.sortableDateTime);case "t":return d.t(h.shortTime);case "T":return d.t(h.longTime);case "u":return g=d.clone().addMinutes(d.getTimezoneOffset()),g.toString(h.universalSortableDateTime);case "y":return d.t(h.yearMonth)}}return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,function(a){if("\\"===a.charAt(0))return a.replace("\\",""); +d.h=d.getHours;switch(a){case "hh":return c(13>d.h()?0===d.h()?12:d.h():d.h()-12);case "h":return 13>d.h()?0===d.h()?12:d.h():d.h()-12;case "HH":return c(d.h());case "H":return d.h();case "mm":return c(d.getMinutes());case "m":return d.getMinutes();case "ss":return c(d.getSeconds());case "s":return d.getSeconds();case "yyyy":return c(d.getFullYear(),4);case "yy":return c(d.getFullYear());case "dddd":return Date.CultureInfo.dayNames[d.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[d.getDay()]; +case "dd":return c(d.getDate());case "d":return d.getDate();case "MMMM":return Date.CultureInfo.monthNames[d.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[d.getMonth()];case "MM":return c(d.getMonth()+1);case "M":return d.getMonth()+1;case "t":return 12>d.h()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>d.h()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(d.getDate());case "W":return d.getWeek(); +case "WW":return d.getISOWeek();case "Q":return"Q"+d.getQuarter();case "q":return String(d.getQuarter());default:return a}}).replace(/\[|\]/g,""):this._toString()}})(); +(function(){Date.Parsing={Exception:function(a){this.message="Parse error at '"+a.substring(0,10)+" ...'"}};var f=Date.Parsing,g=[0,31,59,90,120,151,181,212,243,273,304,334],c=[0,31,60,91,121,152,182,213,244,274,305,335];f.isLeapYear=function(a){return 0===a%4&&0!==a%100||0===a%400};f.processTimeObject=function(a){var b,e;b=new Date;e=f.isLeapYear(a.year)?c:g;a.hours=a.hours?a.hours:0;a.minutes=a.minutes?a.minutes:0;a.seconds=a.seconds?a.seconds:0;a.milliseconds=a.milliseconds?a.milliseconds:0;a.year|| +(a.year=b.getFullYear());if(a.month||!a.week&&!a.dayOfYear)a.month=a.month?a.month:0,a.day=a.day?a.day:1,a.dayOfYear=e[a.month]+a.day;else for(a.dayOfYear||(a.weekDay=a.weekDay||0===a.weekDay?a.weekDay:1,b=new Date(a.year,0,4),b=0===b.getDay()?7:b.getDay(),a.dayOfYear=7*a.week+(0===a.weekDay?7:a.weekDay)-(b+3)),b=0;b<=e.length;b++)if(a.dayOfYeara.length)return e.year=a,f.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bthis.day)throw"invalid day";}},month:function(a){return function(){this.month=3===a.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(a)/4:Number(a)-1;if(0>this.month)throw"invalid month";}},year:function(a){return function(){var b= +Number(a);this.year=2this.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"==this.meridian&&12>this.hour?this.hour+=12: +"a"==this.meridian&&12==this.hour&&(this.hour=0)}if(this.day>f.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");a=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&a.setFullYear(this.year);this.timezone?a.set({timezone:this.timezone}):this.timezoneOffset&&a.set({timezoneOffset:this.timezoneOffset});return a},finish:function(a){a=a instanceof Array?g(a):[a];if(0===a.length)return null;for(var b= +0;bthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"==this.meridian&&12>this.hour?this.hour+=12:"a"==this.meridian&& +12==this.hour&&(this.hour=0)}!this.weekday||"week"===this.unit||this.day||this.days||(c=Date[this.weekday](),this.day=c.getDate(),c.getMonth()!==a.getMonth()&&(this.month=c.getMonth()));!this.month&&0!==this.month||this.day||(this.day=1);if(!this.orient&&!this.operator&&"week"==this.unit&&this.value&&!this.day&&!this.month)return Date.today().setWeek(this.value);if("week"==this.unit&&this.weeks&&!this.day&&!this.month)return a=Date[this.weekday?this.weekday:"today"]().addWeeks(this.weeks),this.now&& +a.setTimeToNow(),a;b&&this.timezone&&this.day&&this.days&&(this.day=this.days);return b?a.add(this):a.set(this)}};var c=f.Parsing.Operators,a=f.Grammar,b=f.Translator,e;a.datePartDelimiter=c.rtoken(/^([\s\-\.\,\/\x27]+)/);a.timePartDelimiter=c.stoken(":");a.whiteSpace=c.rtoken(/^\s*/);a.generalDelimiter=c.rtoken(/^(([\s\,]|at|@|on)+)/);var q={};a.ctoken=function(a){var b=q[a];if(!b){for(var b=Date.CultureInfo.regexPatterns,d=a.split(/\s+/),e=[],f=0;fc)throw new RangeError(f.getDayName(a)+ +" does not occur "+b+" times in the month of "+f.getMonthName(c.getMonth())+" "+c.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},h=function(a){return function(){var b=f.today(),c=a-b.getDay();0===a&&1===Date.CultureInfo.firstDayOfWeek&&0!==b.getDay()&&(c+=7);return b.addDays(c)}},k=0;kf?-1:1,this.setMilliseconds(Math.abs(f)),this.setDays(Math.floor(this.getMilliseconds()/864E5)*e),this.setMilliseconds(this.getMilliseconds()%864E5),this.setHours(Math.floor(this.getMilliseconds()/36E5)*e),this.setMilliseconds(this.getMilliseconds()%36E5),this.setMinutes(Math.floor(this.getMilliseconds()/6E4)*e),this.setMilliseconds(this.getMilliseconds()%6E4),this.setSeconds(Math.floor(this.getMilliseconds()/ +1E3)*e),this.setMilliseconds(this.getMilliseconds()%1E3),this.setMilliseconds(this.getMilliseconds()*e));this.getTotalMilliseconds=function(){return 864E5*this.getDays()+36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)}; +this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/1E3)};this.addDays=function(a){return new TimeSpan(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new TimeSpan(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new TimeSpan(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+ +1E3*a)};this.addMilliseconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g,function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds(); +case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator}}):this._toString()};return this};Date.prototype.getTimeOfDay=function(){return new TimeSpan(0,this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds())}; +var TimePeriod=function(f,g,c,a,b,e,q){for(var d="years months days hours minutes seconds milliseconds".split(/\s+/),l=function(a){return function(){return this[a]}},h=function(a){return function(b){this[a]=b;return this}},k=0;kl?-1:1;this.years=l.getFullYear()-d.getFullYear();h.addYears(this.years);1===k?h>l&&0!==this.years&&this.years--:hl&&d.clone().addDays(-d.getDaysInMonth())>l;)d.addMonths(-1),this.months--;d=l-d;0!==d&&(d=new TimeSpan(d), +this.setDays(d.getDays()),this.setHours(d.getHours()),this.setMinutes(d.getMinutes()),this.setSeconds(d.getSeconds()),this.setMilliseconds(d.getMilliseconds()))}return this}; diff --git a/vendors/DateJS/build/production/date-en-ZA.min.js b/vendors/DateJS/build/production/date-en-ZA.min.js new file mode 100644 index 0000000..b0cf5c1 --- /dev/null +++ b/vendors/DateJS/build/production/date-en-ZA.min.js @@ -0,0 +1,134 @@ +/** + * @overview datejs + * @version 1.0.0-rc3 + * @author Gregory Wild-Smith + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-AR"]={name:"es-AR",englishName:"Spanish (Argentina)",nativeName:"Espa\u00f1ol (Argentina)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-BO"]={name:"es-BO",englishName:"Spanish (Bolivia)",nativeName:"Espa\u00f1ol (Bolivia)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-CL"]={name:"es-CL",englishName:"Spanish (Chile)",nativeName:"Espa\u00f1ol (Chile)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-CO"]={name:"es-CO",englishName:"Spanish (Colombia)",nativeName:"Espa\u00f1ol (Colombia)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-CR"]={name:"es-CR",englishName:"Spanish (Costa Rica)",nativeName:"Espa\u00f1ol (Costa Rica)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-DO"]={name:"es-DO",englishName:"Spanish (Dominican Republic)",nativeName:"Espa\u00f1ol (Rep\u00fablica Dominicana)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-EC"]={name:"es-EC",englishName:"Spanish (Ecuador)",nativeName:"Espa\u00f1ol (Ecuador)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-ES"]={name:"es-ES",englishName:"Spanish (Spain)",nativeName:"espa\u00f1ol (Espa\u00f1a)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-GT"]={name:"es-GT",englishName:"Spanish (Guatemala)",nativeName:"Espa\u00f1ol (Guatemala)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-HN"]={name:"es-HN",englishName:"Spanish (Honduras)",nativeName:"Espa\u00f1ol (Honduras)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-MX"]={name:"es-MX",englishName:"Spanish (Mexico)",nativeName:"Espa\u00f1ol (M\u00e9xico)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-NI"]={name:"es-NI",englishName:"Spanish (Nicaragua)",nativeName:"Espa\u00f1ol (Nicaragua)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-PA"]={name:"es-PA",englishName:"Spanish (Panama)",nativeName:"Espa\u00f1ol (Panam\u00e1)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-PE"]={name:"es-PE",englishName:"Spanish (Peru)",nativeName:"Espa\u00f1ol (Per\u00fa)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-PR"]={name:"es-PR",englishName:"Spanish (Puerto Rico)",nativeName:"Espa\u00f1ol (Puerto Rico)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-PY"]={name:"es-PY",englishName:"Spanish (Paraguay)",nativeName:"Espa\u00f1ol (Paraguay)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-SV"]={name:"es-SV",englishName:"Spanish (El Salvador)",nativeName:"Espa\u00f1ol (El Salvador)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-UY"]={name:"es-UY",englishName:"Spanish (Uruguay)",nativeName:"Espa\u00f1ol (Uruguay)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["es-VE"]={name:"es-VE",englishName:"Spanish (Venezuela)",nativeName:"Espa\u00f1ol (Republica Bolivariana de Venezuela)",Sunday:"domingo",Monday:"lunes",Tuesday:"martes",Wednesday:"mi\u00e9rcoles",Thursday:"jueves",Friday:"viernes",Saturday:"s\u00e1bado",Sun:"dom",Mon:"lun",Tue:"mar",Wed:"mi\u00e9",Thu:"jue",Fri:"vie",Sat:"s\u00e1b",Su:"do",Mo:"lu",Tu:"ma",We:"mi",Th:"ju",Fr:"vi",Sa:"s\u00e1",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(\u00e9(rcoles)?)?","/^th(u(r(s(day)?)?)?)?/":"^ju(e(ves)?)?","/^fr(i(day)?)?/":"^vi(e(rnes)?)?","/^sa(t(urday)?)?/":"^s\u00e1(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["et-EE"]={name:"et-EE",englishName:"Estonian (Estonia)",nativeName:"eesti (Eesti)",Sunday:"p\u00fchap\u00e4ev",Monday:"esmasp\u00e4ev",Tuesday:"teisip\u00e4ev",Wednesday:"kolmap\u00e4ev",Thursday:"neljap\u00e4ev",Friday:"reede",Saturday:"laup\u00e4ev",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\u00e4rts",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\u00e4rts",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\u00e4rts","/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\u00fchap\u00e4ev","/^mo(n(day)?)?/":"^esmasp\u00e4ev","/^tu(e(s(day)?)?)?/":"^teisip\u00e4ev","/^we(d(nesday)?)?/":"^kolmap\u00e4ev","/^th(u(r(s(day)?)?)?)?/":"^neljap\u00e4ev","/^fr(i(day)?)?/":"^reede","/^sa(t(urday)?)?/":"^laup\u00e4ev","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fa-IR"]={name:"fa-IR",englishName:"Persian (Iran)",nativeName:"\u0641\u0627\u0631\u0633\u0649 (\u0627\u064a\u0631\u0627\u0646)",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:"\u0642.\u0638",PM:"\u0628.\u0638",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e4kuu",July:"hein\u00e4kuu",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\u00e4",Jul_Abbr:"hein\u00e4",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\u00e4(kuu)?","/jul(y)?/":"hein\u00e4(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fo-FO"]={name:"fo-FO",englishName:"Faroese (Faroe Islands)",nativeName:"f\u00f8royskt (F\u00f8royar)",Sunday:"sunnudagur",Monday:"m\u00e1nadagur",Tuesday:"t\u00fdsdagur",Wednesday:"mikudagur",Thursday:"h\u00f3sdagur",Friday:"fr\u00edggjadagur",Saturday:"leygardagur",Sun:"sun",Mon:"m\u00e1n",Tue:"t\u00fds",Wed:"mik",Thu:"h\u00f3s",Fri:"fr\u00ed",Sat:"leyg",Su:"su",Mo:"m\u00e1",Tu:"t\u00fd",We:"mi",Th:"h\u00f3",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\u00edl",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(\u00edl)?","/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\u00e1(n(adagur)?)?","/^tu(e(s(day)?)?)?/":"^t\u00fd(s(dagur)?)?","/^we(d(nesday)?)?/":"^mi(k(udagur)?)?","/^th(u(r(s(day)?)?)?)?/":"^h\u00f3(s(dagur)?)?","/^fr(i(day)?)?/":"^fr(\u00ed(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-BE"]={name:"fr-BE",englishName:"French (Belgium)",nativeName:"fran\u00e7ais (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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr(.(ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr(.(il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil(.(let)?)?","/aug(ust)?/":"ao\u00fbt","/sep(t(ember)?)?/":"sept(.(embre)?)?", +"/oct(ober)?/":"oct(.(obre)?)?","/nov(ember)?/":"nov(.(embre)?)?","/dec(ember)?/":"d\u00e9c(.(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-CA"]={name:"fr-CA",englishName:"French (Canada)",nativeName:"fran\u00e7ais (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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr((ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr((il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil((let)?)?","/aug(ust)?/":"ao\u00fbt","/sep(t(ember)?)?/":"sept((embre)?)?", +"/oct(ober)?/":"oct((obre)?)?","/nov(ember)?/":"nov((embre)?)?","/dec(ember)?/":"d\u00e9c((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\u00e9c\u00e9dant","/^(\\-|bef(ore)?|ago)/":"^succ\u00e9dant", +"/^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\u00e9e)?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-CH"]={name:"fr-CH",englishName:"French (Switzerland)",nativeName:"fran\u00e7ais (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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr(.(ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr(.(il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil(.(let)?)?","/aug(ust)?/":"ao\u00fbt", +"/sep(t(ember)?)?/":"sept(.(embre)?)?","/oct(ober)?/":"oct(.(obre)?)?","/nov(ember)?/":"nov(.(embre)?)?","/dec(ember)?/":"d\u00e9c(.(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-FR"]={name:"fr-FR",englishName:"French (France)",nativeName:"fran\u00e7ais (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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr(.(ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr(.(il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil(.(let)?)?","/aug(ust)?/":"ao\u00fbt","/sep(t(ember)?)?/":"sept(.(embre)?)?", +"/oct(ober)?/":"oct(.(obre)?)?","/nov(ember)?/":"nov(.(embre)?)?","/dec(ember)?/":"d\u00e9c(.(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-LU"]={name:"fr-LU",englishName:"French (Luxembourg)",nativeName:"fran\u00e7ais (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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr(.(ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr(.(il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil(.(let)?)?","/aug(ust)?/":"ao\u00fbt","/sep(t(ember)?)?/":"sept(.(embre)?)?", +"/oct(ober)?/":"oct(.(obre)?)?","/nov(ember)?/":"nov(.(embre)?)?","/dec(ember)?/":"d\u00e9c(.(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["fr-MC"]={name:"fr-MC",englishName:"French (Principality of Monaco)",nativeName:"fran\u00e7ais (Principaut\u00e9 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\u00e9vrier",March:"mars",April:"avril",May:"mai",June:"juin",July:"juillet",August:"ao\u00fbt",September:"septembre",October:"octobre",November:"novembre",December:"d\u00e9cembre",Jan_Abbr:"janv.",Feb_Abbr:"f\u00e9vr.",Mar_Abbr:"mars",Apr_Abbr:"avr.",May_Abbr:"mai",Jun_Abbr:"juin",Jul_Abbr:"juil.",Aug_Abbr:"ao\u00fbt",Sep_Abbr:"sept.",Oct_Abbr:"oct.",Nov_Abbr:"nov.",Dec_Abbr:"d\u00e9c.",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\u00e9vr(.(ier)?)?","/mar(ch)?/":"mars","/apr(il)?/":"avr(.(il)?)?","/may/":"mai","/jun(e)?/":"juin","/jul(y)?/":"juil(.(let)?)?", +"/aug(ust)?/":"ao\u00fbt","/sep(t(ember)?)?/":"sept(.(embre)?)?","/oct(ober)?/":"oct(.(obre)?)?","/nov(ember)?/":"nov(.(embre)?)?","/dec(ember)?/":"d\u00e9c(.(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u00e9rcores",Thursday:"xoves",Friday:"venres",Saturday:"s\u00e1bado",Sun:"dom",Mon:"luns",Tue:"mar",Wed:"m\u00e9r",Thu:"xov",Fri:"ven",Sat:"sab",Su:"do",Mo:"lu",Tu:"ma",We:"m\u00e9",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\u00f1o",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\u00f1",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\u00f1(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\u00e9(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["gu-IN"]={name:"gu-IN",englishName:"Gujarati (India)",nativeName:"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0 (\u0aad\u0abe\u0ab0\u0aa4)",Sunday:"\u0ab0\u0ab5\u0abf\u0ab5\u0abe\u0ab0",Monday:"\u0ab8\u0acb\u0aae\u0ab5\u0abe\u0ab0",Tuesday:"\u0aae\u0a82\u0a97\u0ab3\u0ab5\u0abe\u0ab0",Wednesday:"\u0aac\u0ac1\u0aa7\u0ab5\u0abe\u0ab0",Thursday:"\u0a97\u0ac1\u0ab0\u0ac1\u0ab5\u0abe\u0ab0",Friday:"\u0ab6\u0ac1\u0a95\u0acd\u0ab0\u0ab5\u0abe\u0ab0",Saturday:"\u0ab6\u0aa8\u0abf\u0ab5\u0abe\u0ab0", +Sun:"\u0ab0\u0ab5\u0abf",Mon:"\u0ab8\u0acb\u0aae",Tue:"\u0aae\u0a82\u0a97\u0ab3",Wed:"\u0aac\u0ac1\u0aa7",Thu:"\u0a97\u0ac1\u0ab0\u0ac1",Fri:"\u0ab6\u0ac1\u0a95\u0acd\u0ab0",Sat:"\u0ab6\u0aa8\u0abf",Su:"\u0ab0",Mo:"\u0ab8",Tu:"\u0aae",We:"\u0aac",Th:"\u0a97",Fr:"\u0ab6",Sa:"\u0ab6",S_Sun_Initial:"\u0ab0",M_Mon_Initial:"\u0ab8",T_Tue_Initial:"\u0aae",W_Wed_Initial:"\u0aac",T_Thu_Initial:"\u0a97",F_Fri_Initial:"\u0ab6",S_Sat_Initial:"\u0ab6",January:"\u0a9c\u0abe\u0aa8\u0acd\u0aaf\u0ac1\u0a86\u0ab0\u0ac0", +February:"\u0aab\u0ac7\u0aac\u0acd\u0ab0\u0ac1\u0a86\u0ab0\u0ac0",March:"\u0aae\u0abe\u0ab0\u0acd\u0a9a",April:"\u0a8f\u0aaa\u0acd\u0ab0\u0abf\u0ab2",May:"\u0aae\u0ac7",June:"\u0a9c\u0ac2\u0aa8",July:"\u0a9c\u0ac1\u0ab2\u0abe\u0a88",August:"\u0a91\u0a97\u0ab8\u0acd\u0a9f",September:"\u0ab8\u0aaa\u0acd\u0a9f\u0ac7\u0aae\u0acd\u0aac\u0ab0",October:"\u0a91\u0a95\u0acd\u0a9f\u0acd\u0aac\u0ab0",November:"\u0aa8\u0ab5\u0ac7\u0aae\u0acd\u0aac\u0ab0",December:"\u0aa1\u0abf\u0ab8\u0ac7\u0aae\u0acd\u0aac\u0ab0", +Jan_Abbr:"\u0a9c\u0abe\u0aa8\u0acd\u0aaf\u0ac1",Feb_Abbr:"\u0aab\u0ac7\u0aac\u0acd\u0ab0\u0ac1",Mar_Abbr:"\u0aae\u0abe\u0ab0\u0acd\u0a9a",Apr_Abbr:"\u0a8f\u0aaa\u0acd\u0ab0\u0abf\u0ab2",May_Abbr:"\u0aae\u0ac7",Jun_Abbr:"\u0a9c\u0ac2\u0aa8",Jul_Abbr:"\u0a9c\u0ac1\u0ab2\u0abe\u0a88",Aug_Abbr:"\u0a91\u0a97\u0ab8\u0acd\u0a9f",Sep_Abbr:"\u0ab8\u0aaa\u0acd\u0a9f\u0ac7",Oct_Abbr:"\u0a91\u0a95\u0acd\u0a9f\u0acb",Nov_Abbr:"\u0aa8\u0ab5\u0ac7",Dec_Abbr:"\u0aa1\u0abf\u0ab8\u0ac7",AM:"\u0aaa\u0ac2\u0ab0\u0acd\u0ab5\u00a0\u0aae\u0aa7\u0acd\u0aaf\u0abe\u0ab9\u0acd\u0aa8", +PM:"\u0a89\u0aa4\u0acd\u0aa4\u0ab0\u00a0\u0aae\u0aa7\u0acd\u0aaf\u0abe\u0ab9\u0acd\u0aa8",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)?/":"\u0a9c\u0abe\u0aa8\u0acd\u0aaf\u0ac1(\u0a86\u0ab0\u0ac0)?", +"/feb(ruary)?/":"\u0aab\u0ac7\u0aac\u0acd\u0ab0\u0ac1(\u0a86\u0ab0\u0ac0)?","/mar(ch)?/":"\u0aae\u0abe\u0ab0\u0acd\u0a9a","/apr(il)?/":"\u0a8f\u0aaa\u0acd\u0ab0\u0abf\u0ab2","/may/":"\u0aae\u0ac7","/jun(e)?/":"\u0a9c\u0ac2\u0aa8","/jul(y)?/":"\u0a9c\u0ac1\u0ab2\u0abe\u0a88","/aug(ust)?/":"\u0a91\u0a97\u0ab8\u0acd\u0a9f","/sep(t(ember)?)?/":"\u0ab8\u0aaa\u0acd\u0a9f\u0ac7(\u0aae\u0acd\u0aac\u0ab0)?","/oct(ober)?/":"\u0a91\u0a95\u0acd\u0a9f\u0acd\u0aac\u0ab0","/nov(ember)?/":"\u0aa8\u0ab5\u0ac7(\u0aae\u0acd\u0aac\u0ab0)?", +"/dec(ember)?/":"\u0aa1\u0abf\u0ab8\u0ac7(\u0aae\u0acd\u0aac\u0ab0)?","/^su(n(day)?)?/":"^\u0ab0(\u0ab5\u0abf(\u0ab5\u0abe\u0ab0)?)?","/^mo(n(day)?)?/":"^\u0ab8(\u0acb\u0aae(\u0ab5\u0abe\u0ab0)?)?","/^tu(e(s(day)?)?)?/":"^\u0aae(\u0a82\u0a97\u0ab3(\u0ab5\u0abe\u0ab0)?)?","/^we(d(nesday)?)?/":"^\u0aac(\u0ac1\u0aa7(\u0ab5\u0abe\u0ab0)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0a97(\u0ac1\u0ab0\u0ac1(\u0ab5\u0abe\u0ab0)?)?","/^fr(i(day)?)?/":"^\u0ab6(\u0ac1\u0a95\u0acd\u0ab0(\u0ab5\u0abe\u0ab0)?)?","/^sa(t(urday)?)?/":"^\u0ab6(\u0aa8\u0abf(\u0ab5\u0abe\u0ab0)?)?", +"/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?", +"/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST", +CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["he-IL"]={name:"he-IL",englishName:"Hebrew (Israel)",nativeName:"\u05e2\u05d1\u05e8\u05d9\u05ea (\u05d9\u05e9\u05e8\u05d0\u05dc)",Sunday:"\u05d9\u05d5\u05dd\u00a0\u05e8\u05d0\u05e9\u05d5\u05df",Monday:"\u05d9\u05d5\u05dd\u00a0\u05e9\u05e0\u05d9",Tuesday:"\u05d9\u05d5\u05dd\u00a0\u05e9\u05dc\u05d9\u05e9\u05d9",Wednesday:"\u05d9\u05d5\u05dd\u00a0\u05e8\u05d1\u05d9\u05e2\u05d9",Thursday:"\u05d9\u05d5\u05dd\u00a0\u05d7\u05de\u05d9\u05e9\u05d9",Friday:"\u05d9\u05d5\u05dd\u00a0\u05e9\u05d9\u05e9\u05d9", +Saturday:"\u05e9\u05d1\u05ea",Sun:"\u05d9\u05d5\u05dd\u00a0\u05d0",Mon:"\u05d9\u05d5\u05dd\u00a0\u05d1",Tue:"\u05d9\u05d5\u05dd\u00a0\u05d2",Wed:"\u05d9\u05d5\u05dd\u00a0\u05d3",Thu:"\u05d9\u05d5\u05dd\u00a0\u05d4",Fri:"\u05d9\u05d5\u05dd\u00a0\u05d5",Sat:"\u05e9\u05d1\u05ea",Su:"\u05d0",Mo:"\u05d1",Tu:"\u05d2",We:"\u05d3",Th:"\u05d4",Fr:"\u05d5",Sa:"\u05e9",S_Sun_Initial:"\u05d0",M_Mon_Initial:"\u05d1",T_Tue_Initial:"\u05d2",W_Wed_Initial:"\u05d3",T_Thu_Initial:"\u05d4",F_Fri_Initial:"\u05d5",S_Sat_Initial:"\u05e9", +January:"\u05d9\u05e0\u05d5\u05d0\u05e8",February:"\u05e4\u05d1\u05e8\u05d5\u05d0\u05e8",March:"\u05de\u05e8\u05e5",April:"\u05d0\u05e4\u05e8\u05d9\u05dc",May:"\u05de\u05d0\u05d9",June:"\u05d9\u05d5\u05e0\u05d9",July:"\u05d9\u05d5\u05dc\u05d9",August:"\u05d0\u05d5\u05d2\u05d5\u05e1\u05d8",September:"\u05e1\u05e4\u05d8\u05de\u05d1\u05e8",October:"\u05d0\u05d5\u05e7\u05d8\u05d5\u05d1\u05e8",November:"\u05e0\u05d5\u05d1\u05de\u05d1\u05e8",December:"\u05d3\u05e6\u05de\u05d1\u05e8",Jan_Abbr:"\u05d9\u05e0\u05d5", +Feb_Abbr:"\u05e4\u05d1\u05e8",Mar_Abbr:"\u05de\u05e8\u05e5",Apr_Abbr:"\u05d0\u05e4\u05e8",May_Abbr:"\u05de\u05d0\u05d9",Jun_Abbr:"\u05d9\u05d5\u05e0",Jul_Abbr:"\u05d9\u05d5\u05dc",Aug_Abbr:"\u05d0\u05d5\u05d2",Sep_Abbr:"\u05e1\u05e4\u05d8",Oct_Abbr:"\u05d0\u05d5\u05e7",Nov_Abbr:"\u05e0\u05d5\u05d1",Dec_Abbr:"\u05d3\u05e6\u05de",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)?/":"\u05d9\u05e0\u05d5(\u05d0\u05e8)?","/feb(ruary)?/":"\u05e4\u05d1\u05e8(\u05d5\u05d0\u05e8)?","/mar(ch)?/":"\u05de\u05e8\u05e5","/apr(il)?/":"\u05d0\u05e4\u05e8(\u05d9\u05dc)?","/may/":"\u05de\u05d0\u05d9","/jun(e)?/":"\u05d9\u05d5\u05e0(\u05d9)?", +"/jul(y)?/":"\u05d9\u05d5\u05dc(\u05d9)?","/aug(ust)?/":"\u05d0\u05d5\u05d2(\u05d5\u05e1\u05d8)?","/sep(t(ember)?)?/":"\u05e1\u05e4\u05d8(\u05de\u05d1\u05e8)?","/oct(ober)?/":"\u05d0\u05d5\u05e7(\u05d8\u05d5\u05d1\u05e8)?","/nov(ember)?/":"\u05e0\u05d5\u05d1(\u05de\u05d1\u05e8)?","/dec(ember)?/":"\u05d3\u05e6\u05de(\u05d1\u05e8)?","/^su(n(day)?)?/":"^\u05d0(\u05d5\u05dd\u00a0\u05d0(\u05d0\u05e9\u05d5\u05df)?)?","/^mo(n(day)?)?/":"^\u05d1(\u05d5\u05dd\u00a0\u05d1(\u05e0\u05d9)?)?","/^tu(e(s(day)?)?)?/":"^\u05d2(\u05d5\u05dd\u00a0\u05d2(\u05dc\u05d9\u05e9\u05d9)?)?", +"/^we(d(nesday)?)?/":"^\u05d3(\u05d5\u05dd\u00a0\u05d3(\u05d1\u05d9\u05e2\u05d9)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u05d4(\u05d5\u05dd\u00a0\u05d4(\u05de\u05d9\u05e9\u05d9)?)?","/^fr(i(day)?)?/":"^\u05d5(\u05d5\u05dd\u00a0\u05d5(\u05d9\u05e9\u05d9)?)?","/^sa(t(urday)?)?/":"^\u05e9(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["hi-IN"]={name:"hi-IN",englishName:"Hindi (India)",nativeName:"\u0939\u093f\u0902\u0926\u0940 (\u092d\u093e\u0930\u0924)",Sunday:"\u0930\u0935\u093f\u0935\u093e\u0930",Monday:"\u0938\u094b\u092e\u0935\u093e\u0930",Tuesday:"\u092e\u0902\u0917\u0932\u0935\u093e\u0930",Wednesday:"\u092c\u0941\u0927\u0935\u093e\u0930",Thursday:"\u0917\u0941\u0930\u0941\u0935\u093e\u0930",Friday:"\u0936\u0941\u0915\u094d\u0930\u0935\u093e\u0930",Saturday:"\u0936\u0928\u093f\u0935\u093e\u0930",Sun:"\u0930\u0935\u093f.", +Mon:"\u0938\u094b\u092e.",Tue:"\u092e\u0902\u0917\u0932.",Wed:"\u092c\u0941\u0927.",Thu:"\u0917\u0941\u0930\u0941.",Fri:"\u0936\u0941\u0915\u094d\u0930.",Sat:"\u0936\u0928\u093f.",Su:"\u0930",Mo:"\u0938",Tu:"\u092e",We:"\u092c",Th:"\u0917",Fr:"\u0936",Sa:"\u0936",S_Sun_Initial:"\u0930",M_Mon_Initial:"\u0938",T_Tue_Initial:"\u092e",W_Wed_Initial:"\u092c",T_Thu_Initial:"\u0917",F_Fri_Initial:"\u0936",S_Sat_Initial:"\u0936",January:"\u091c\u0928\u0935\u0930\u0940",February:"\u092b\u0930\u0935\u0930\u0940", +March:"\u092e\u093e\u0930\u094d\u091a",April:"\u0905\u092a\u094d\u0930\u0948\u0932",May:"\u092e\u0908",June:"\u091c\u0942\u0928",July:"\u091c\u0941\u0932\u093e\u0908",August:"\u0905\u0917\u0938\u094d\u0924",September:"\u0938\u093f\u0924\u092e\u094d\u092c\u0930",October:"\u0905\u0915\u094d\u0924\u0942\u092c\u0930",November:"\u0928\u0935\u092e\u094d\u092c\u0930",December:"\u0926\u093f\u0938\u092e\u094d\u092c\u0930",Jan_Abbr:"\u091c\u0928\u0935\u0930\u0940",Feb_Abbr:"\u092b\u0930\u0935\u0930\u0940", +Mar_Abbr:"\u092e\u093e\u0930\u094d\u091a",Apr_Abbr:"\u0905\u092a\u094d\u0930\u0948\u0932",May_Abbr:"\u092e\u0908",Jun_Abbr:"\u091c\u0942\u0928",Jul_Abbr:"\u091c\u0941\u0932\u093e\u0908",Aug_Abbr:"\u0905\u0917\u0938\u094d\u0924",Sep_Abbr:"\u0938\u093f\u0924\u092e\u094d\u092c\u0930",Oct_Abbr:"\u0905\u0915\u094d\u0924\u0942\u092c\u0930",Nov_Abbr:"\u0928\u0935\u092e\u094d\u092c\u0930",Dec_Abbr:"\u0926\u093f\u0938\u092e\u094d\u092c\u0930",AM:"\u092a\u0942\u0930\u094d\u0935\u093e\u0939\u094d\u0928",PM:"\u0905\u092a\u0930\u093e\u0939\u094d\u0928", +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)?/":"\u091c\u0928\u0935\u0930\u0940","/feb(ruary)?/":"\u092b\u0930\u0935\u0930\u0940","/mar(ch)?/":"\u092e\u093e\u0930\u094d\u091a", +"/apr(il)?/":"\u0905\u092a\u094d\u0930\u0948\u0932","/may/":"\u092e\u0908","/jun(e)?/":"\u091c\u0942\u0928","/jul(y)?/":"\u091c\u0941\u0932\u093e\u0908","/aug(ust)?/":"\u0905\u0917\u0938\u094d\u0924","/sep(t(ember)?)?/":"\u0938\u093f\u0924\u092e\u094d\u092c\u0930","/oct(ober)?/":"\u0905\u0915\u094d\u0924\u0942\u092c\u0930","/nov(ember)?/":"\u0928\u0935\u092e\u094d\u092c\u0930","/dec(ember)?/":"\u0926\u093f\u0938\u092e\u094d\u092c\u0930","/^su(n(day)?)?/":"^\u0930(\u0935\u093f(.(\u0935\u093e\u0930)?)?)?", +"/^mo(n(day)?)?/":"^\u0938(\u094b\u092e(.(\u0935\u093e\u0930)?)?)?","/^tu(e(s(day)?)?)?/":"^\u092e(\u0902\u0917\u0932(.(\u0935\u093e\u0930)?)?)?","/^we(d(nesday)?)?/":"^\u092c(\u0941\u0927(.(\u0935\u093e\u0930)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0917(\u0941\u0930\u0941(.(\u0935\u093e\u0930)?)?)?","/^fr(i(day)?)?/":"^\u0936(\u0941\u0915\u094d\u0930(.(\u0935\u093e\u0930)?)?)?","/^sa(t(urday)?)?/":"^\u0936(\u0928\u093f(.(\u0935\u093e\u0930)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detvrtak",Friday:"petak",Saturday:"subota",Sun:"ned",Mon:"pon",Tue:"uto",Wed:"sri",Thu:"\u010det",Fri:"pet",Sat:"sub",Su:"ned",Mo:"pon",Tu:"uto",We:"sri",Th:"\u010det",Fr:"pet",Sa:"sub",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u010d", +F_Fri_Initial:"p",S_Sat_Initial:"s",January:"sije\u010danj",February:"velja\u010da",March:"o\u017eujak",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\u017eu",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\u010danj)?","/feb(ruary)?/":"velja\u010da","/mar(ch)?/":"o\u017eu(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)?)?)?)?/":"^\u010detvrtak","/^fr(i(day)?)?/":"^petak","/^sa(t(urday)?)?/":"^subota","/^next/":"^slijede\u0107(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\u010der","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detvrtak",Friday:"petak",Saturday:"subota",Sun:"ned",Mon:"pon",Tue:"uto",Wed:"sri",Thu:"\u010det",Fri:"pet",Sat:"sub",Su:"ne",Mo:"po",Tu:"ut",We:"sr",Th:"\u010de",Fr:"pe",Sa:"su",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u010d",F_Fri_Initial:"p",S_Sat_Initial:"s", +January:"sije\u010danj",February:"velja\u010da",March:"o\u017eujak",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\u017eu",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\u010danj)?","/feb(ruary)?/":"velja\u010da","/mar(ch)?/":"o\u017eu(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)?)?)?)?/":"^\u010de(t(vrtak)?)?","/^fr(i(day)?)?/":"^pe(t(ak)?)?","/^sa(t(urday)?)?/":"^su(b(ota)?)?","/^next/":"^slijede\u0107(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\u010der","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["hu-HU"]={name:"hu-HU",englishName:"Hungarian (Hungary)",nativeName:"magyar (Magyarorsz\u00e1g)",Sunday:"vas\u00e1rnap",Monday:"h\u00e9tf\u0151",Tuesday:"kedd",Wednesday:"szerda",Thursday:"cs\u00fct\u00f6rt\u00f6k",Friday:"p\u00e9ntek",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\u00e1r",February:"febru\u00e1r",March:"m\u00e1rcius",April:"\u00e1prilis",May:"m\u00e1jus",June:"j\u00fanius",July:"j\u00falius",August:"augusztus",September:"szeptember",October:"okt\u00f3ber",November:"november",December:"december",Jan_Abbr:"jan.",Feb_Abbr:"febr.",Mar_Abbr:"m\u00e1rc.",Apr_Abbr:"\u00e1pr.",May_Abbr:"m\u00e1j.",Jun_Abbr:"j\u00fan.",Jul_Abbr:"j\u00fal.",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\u00e1r)?)?","/feb(ruary)?/":"febr(.(u\u00e1r)?)?","/mar(ch)?/":"m\u00e1rc(.(ius)?)?","/apr(il)?/":"\u00e1pr(.(ilis)?)?", +"/may/":"m\u00e1j(.(us)?)?","/jun(e)?/":"j\u00fan(.(ius)?)?","/jul(y)?/":"j\u00fal(.(ius)?)?","/aug(ust)?/":"aug(.(usztus)?)?","/sep(t(ember)?)?/":"szept(.(ember)?)?","/oct(ober)?/":"okt(.(\u00f3ber)?)?","/nov(ember)?/":"nov(.(ember)?)?","/dec(ember)?/":"dec(.(ember)?)?","/^su(n(day)?)?/":"^vas\u00e1rnap","/^mo(n(day)?)?/":"^h\u00e9tf\u0151","/^tu(e(s(day)?)?)?/":"^kedd","/^we(d(nesday)?)?/":"^szerda","/^th(u(r(s(day)?)?)?)?/":"^cs\u00fct\u00f6rt\u00f6k","/^fr(i(day)?)?/":"^p\u00e9ntek","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["hy-AM"]={name:"hy-AM",englishName:"Armenian (Armenia)",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576 (\u0540\u0561\u0575\u0561\u057d\u057f\u0561\u0576)",Sunday:"\u053f\u056b\u0580\u0561\u056f\u056b",Monday:"\u0535\u0580\u056f\u0578\u0582\u0577\u0561\u0562\u0569\u056b",Tuesday:"\u0535\u0580\u0565\u0584\u0577\u0561\u0562\u0569\u056b",Wednesday:"\u0549\u0578\u0580\u0565\u0584\u0577\u0561\u0562\u0569\u056b",Thursday:"\u0540\u056b\u0576\u0563\u0577\u0561\u0562\u0569\u056b",Friday:"\u0548\u0552\u0580\u0562\u0561\u0569", +Saturday:"\u0547\u0561\u0562\u0561\u0569",Sun:"\u053f\u056b\u0580",Mon:"\u0535\u0580\u056f",Tue:"\u0535\u0580\u0584",Wed:"\u0549\u0580\u0584",Thu:"\u0540\u0576\u0563",Fri:"\u0548\u0552\u0580",Sat:"\u0547\u0562\u0569",Su:"\u053f",Mo:"\u0535",Tu:"\u0535",We:"\u0549",Th:"\u0540",Fr:"\u0548",Sa:"\u0547",S_Sun_Initial:"\u053f",M_Mon_Initial:"\u0535",T_Tue_Initial:"\u0535",W_Wed_Initial:"\u0549",T_Thu_Initial:"\u0540",F_Fri_Initial:"\u0548",S_Sat_Initial:"\u0547",January:"\u0540\u0578\u0582\u0576\u057e\u0561\u0580", +February:"\u0553\u0565\u057f\u0580\u057e\u0561\u0580",March:"\u0544\u0561\u0580\u057f",April:"\u0531\u057a\u0580\u056b\u056c",May:"\u0544\u0561\u0575\u056b\u057d",June:"\u0540\u0578\u0582\u0576\u056b\u057d",July:"\u0540\u0578\u0582\u056c\u056b\u057d",August:"\u0555\u0563\u0578\u057d\u057f\u0578\u057d",September:"\u054d\u0565\u057a\u057f\u0565\u0574\u0562\u0565\u0580",October:"\u0540\u0578\u056f\u057f\u0565\u0574\u0562\u0565\u0580",November:"\u0546\u0578\u0575\u0565\u0574\u0562\u0565\u0580",December:"\u0534\u0565\u056f\u057f\u0565\u0574\u0562\u0565\u0580", +Jan_Abbr:"\u0540\u0546\u054e",Feb_Abbr:"\u0553\u054f\u054e",Mar_Abbr:"\u0544\u0550\u054f",Apr_Abbr:"\u0531\u054a\u0550",May_Abbr:"\u0544\u0545\u054d",Jun_Abbr:"\u0540\u0546\u054d",Jul_Abbr:"\u0540\u053c\u054d",Aug_Abbr:"\u0555\u0533\u054d",Sep_Abbr:"\u054d\u0535\u054a",Oct_Abbr:"\u0540\u0548\u053f",Nov_Abbr:"\u0546\u0548\u0545",Dec_Abbr:"\u0534\u0535\u053f",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)?/":"\u0570\u0578\u0582\u0576\u057e\u0561\u0580","/feb(ruary)?/":"\u0583\u0565\u057f\u0580\u057e\u0561\u0580","/mar(ch)?/":"\u0574\u0561\u0580\u057f","/apr(il)?/":"\u0561\u057a\u0580(\u056b\u056c)?","/may/":"\u0574\u0561\u0575\u056b\u057d","/jun(e)?/":"\u0570\u0578\u0582\u0576\u056b\u057d", +"/jul(y)?/":"\u0570\u0578\u0582\u056c\u056b\u057d","/aug(ust)?/":"\u0585\u0563\u0578\u057d\u057f\u0578\u057d","/sep(t(ember)?)?/":"\u057d\u0565\u057a(\u057f\u0565\u0574\u0562\u0565\u0580)?","/oct(ober)?/":"\u0570\u0578\u056f(\u057f\u0565\u0574\u0562\u0565\u0580)?","/nov(ember)?/":"\u0576\u0578\u0575(\u0565\u0574\u0562\u0565\u0580)?","/dec(ember)?/":"\u0564\u0565\u056f(\u057f\u0565\u0574\u0562\u0565\u0580)?","/^su(n(day)?)?/":"^\u056f(\u056b\u0580(\u0561\u056f\u056b)?)?","/^mo(n(day)?)?/":"^\u0565(\u0580\u056f(\u0578\u0582\u0577\u0561\u0562\u0569\u056b)?)?", +"/^tu(e(s(day)?)?)?/":"^\u0565(\u0580\u0584(\u0584\u0577\u0561\u0562\u0569\u056b)?)?","/^we(d(nesday)?)?/":"^\u0579(\u0580\u0584(\u0565\u0584\u0577\u0561\u0562\u0569\u056b)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0570(\u0576\u0563(\u0563\u0577\u0561\u0562\u0569\u056b)?)?","/^fr(i(day)?)?/":"^\u0578(\u0582\u0580(\u0562\u0561\u0569)?)?","/^sa(t(urday)?)?/":"^\u0577(\u0562\u0569(\u0561\u0569)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["is-IS"]={name:"is-IS",englishName:"Icelandic (Iceland)",nativeName:"\u00edslenska (\u00cdsland)",Sunday:"sunnudagur",Monday:"m\u00e1nudagur",Tuesday:"\u00feri\u00f0judagur",Wednesday:"mi\u00f0vikudagur",Thursday:"fimmtudagur",Friday:"f\u00f6studagur",Saturday:"laugardagur",Sun:"sun.",Mon:"m\u00e1n.",Tue:"\u00feri.",Wed:"mi\u00f0.",Thu:"fim.",Fri:"f\u00f6s.",Sat:"lau.",Su:"su",Mo:"m\u00e1",Tu:"\u00fer",We:"mi",Th:"fi",Fr:"f\u00f6",Sa:"la",S_Sun_Initial:"s",M_Mon_Initial:"m",T_Tue_Initial:"\u00fe", +W_Wed_Initial:"m",T_Thu_Initial:"f",F_Fri_Initial:"f",S_Sat_Initial:"l",January:"jan\u00faar",February:"febr\u00faar",March:"mars",April:"apr\u00edl",May:"ma\u00ed",June:"j\u00fan\u00ed",July:"j\u00fal\u00ed",August:"\u00e1g\u00fast",September:"september",October:"okt\u00f3ber",November:"n\u00f3vember",December:"desember",Jan_Abbr:"jan.",Feb_Abbr:"feb.",Mar_Abbr:"mar.",Apr_Abbr:"apr.",May_Abbr:"ma\u00ed",Jun_Abbr:"j\u00fan.",Jul_Abbr:"j\u00fal.",Aug_Abbr:"\u00e1g\u00fa.",Sep_Abbr:"sep.",Oct_Abbr:"okt.", +Nov_Abbr:"n\u00f3v.",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(.(\u00faar)?)?","/feb(ruary)?/":"feb(.(r\u00faar)?)?", +"/mar(ch)?/":"mar(.(s)?)?","/apr(il)?/":"apr(.(\u00edl)?)?","/may/":"ma\u00ed","/jun(e)?/":"j\u00fan(.(\u00ed)?)?","/jul(y)?/":"j\u00fal(.(\u00ed)?)?","/aug(ust)?/":"\u00e1g\u00fa(.(st)?)?","/sep(t(ember)?)?/":"sep(t(ember)?)?","/oct(ober)?/":"okt(.(\u00f3ber)?)?","/nov(ember)?/":"n\u00f3v(.(ember)?)?","/dec(ember)?/":"des(.(ember)?)?","/^su(n(day)?)?/":"^su(n(.(nudagur)?)?)?","/^mo(n(day)?)?/":"^m\u00e1(n(.(udagur)?)?)?","/^tu(e(s(day)?)?)?/":"^\u00fer(i(.(\u00f0judagur)?)?)?","/^we(d(nesday)?)?/":"^mi(\u00f0(.(vikudagur)?)?)?", +"/^th(u(r(s(day)?)?)?)?/":"^fi(m(.(mtudagur)?)?)?","/^fr(i(day)?)?/":"^f\u00f6(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["it-CH"]={name:"it-CH",englishName:"Italian (Switzerland)",nativeName:"italiano (Svizzera)",Sunday:"domenica",Monday:"luned\u00ec",Tuesday:"marted\u00ec",Wednesday:"mercoled\u00ec",Thursday:"gioved\u00ec",Friday:"venerd\u00ec",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\u00ec)?)?","/^tu(e(s(day)?)?)?/":"^ma(r(ted\u00ec)?)?","/^we(d(nesday)?)?/":"^me(r(coled\u00ec)?)?","/^th(u(r(s(day)?)?)?)?/":"^gi(o(ved\u00ec)?)?","/^fr(i(day)?)?/":"^ve(n(erd\u00ec)?)?","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["it-IT"]={name:"it-IT",englishName:"Italian (Italy)",nativeName:"italiano (Italia)",Sunday:"domenica",Monday:"luned\u00ec",Tuesday:"marted\u00ec",Wednesday:"mercoled\u00ec",Thursday:"gioved\u00ec",Friday:"venerd\u00ec",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\u00ec)?)?","/^tu(e(s(day)?)?)?/":"^ma(r(ted\u00ec)?)?","/^we(d(nesday)?)?/":"^me(r(coled\u00ec)?)?","/^th(u(r(s(day)?)?)?)?/":"^gi(o(ved\u00ec)?)?","/^fr(i(day)?)?/":"^ve(n(erd\u00ec)?)?","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ja-JP"]={name:"ja-JP",englishName:"Japanese (Japan)",nativeName:"\u65e5\u672c\u8a9e (\u65e5\u672c)",Sunday:"\u65e5\u66dc\u65e5",Monday:"\u6708\u66dc\u65e5",Tuesday:"\u706b\u66dc\u65e5",Wednesday:"\u6c34\u66dc\u65e5",Thursday:"\u6728\u66dc\u65e5",Friday:"\u91d1\u66dc\u65e5",Saturday:"\u571f\u66dc\u65e5",Sun:"\u65e5",Mon:"\u6708",Tue:"\u706b",Wed:"\u6c34",Thu:"\u6728",Fri:"\u91d1",Sat:"\u571f",Su:"\u65e5",Mo:"\u6708",Tu:"\u706b",We:"\u6c34",Th:"\u6728",Fr:"\u91d1",Sa:"\u571f",S_Sun_Initial:"\u65e5", +M_Mon_Initial:"\u6708",T_Tue_Initial:"\u706b",W_Wed_Initial:"\u6c34",T_Thu_Initial:"\u6728",F_Fri_Initial:"\u91d1",S_Sat_Initial:"\u571f",January:"1\u6708",February:"2\u6708",March:"3\u6708",April:"4\u6708",May:"5\u6708",June:"6\u6708",July:"7\u6708",August:"8\u6708",September:"9\u6708",October:"10\u6708",November:"11\u6708",December:"12\u6708",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:"\u5348\u524d",PM:"\u5348\u5f8c",firstDayOfWeek:0,twoDigitYearMax:2029,mdy:"ymd","M/d/yyyy":"yyyy/MM/dd","dddd, MMMM dd, yyyy":"yyyy'\u5e74'M'\u6708'd'\u65e5'","h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy'\u5e74'M'\u6708'd'\u65e5' 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'\u6708'd'\u65e5'","MMMM, yyyy":"yyyy'\u5e74'M'\u6708'","/jan(uary)?/":"1(\u6708)?", +"/feb(ruary)?/":"2(\u6708)?","/mar(ch)?/":"3(\u6708)?","/apr(il)?/":"4(\u6708)?","/may/":"5(\u6708)?","/jun(e)?/":"6(\u6708)?","/jul(y)?/":"7(\u6708)?","/aug(ust)?/":"8(\u6708)?","/sep(t(ember)?)?/":"9(\u6708)?","/oct(ober)?/":"10(\u6708)?","/nov(ember)?/":"11(\u6708)?","/dec(ember)?/":"12(\u6708)?","/^su(n(day)?)?/":"^\u65e5\u66dc\u65e5","/^mo(n(day)?)?/":"^\u6708\u66dc\u65e5","/^tu(e(s(day)?)?)?/":"^\u706b\u66dc\u65e5","/^we(d(nesday)?)?/":"^\u6c34\u66dc\u65e5","/^th(u(r(s(day)?)?)?)?/":"^\u6728\u66dc\u65e5", +"/^fr(i(day)?)?/":"^\u91d1\u66dc\u65e5","/^sa(t(urday)?)?/":"^\u571f\u66dc\u65e5","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?", +"/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST", +NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ka-GE"]={name:"ka-GE",englishName:"Georgian (Georgia)",nativeName:"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8 (\u10e1\u10d0\u10e5\u10d0\u10e0\u10d7\u10d5\u10d4\u10da\u10dd)",Sunday:"\u10d9\u10d5\u10d8\u10e0\u10d0",Monday:"\u10dd\u10e0\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Tuesday:"\u10e1\u10d0\u10db\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Wednesday:"\u10dd\u10d7\u10ee\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Thursday:"\u10ee\u10e3\u10d7\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Friday:"\u10de\u10d0\u10e0\u10d0\u10e1\u10d9\u10d4\u10d5\u10d8", +Saturday:"\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Sun:"\u10d9\u10d5\u10d8\u10e0\u10d0",Mon:"\u10dd\u10e0\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Tue:"\u10e1\u10d0\u10db\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Wed:"\u10dd\u10d7\u10ee\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Thu:"\u10ee\u10e3\u10d7\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Fri:"\u10de\u10d0\u10e0\u10d0\u10e1\u10d9\u10d4\u10d5\u10d8",Sat:"\u10e8\u10d0\u10d1\u10d0\u10d7\u10d8",Su:"\u10d9",Mo:"\u10dd",Tu:"\u10e1",We:"\u10dd",Th:"\u10ee",Fr:"\u10de",Sa:"\u10e8", +S_Sun_Initial:"\u10d9",M_Mon_Initial:"\u10dd",T_Tue_Initial:"\u10e1",W_Wed_Initial:"\u10dd",T_Thu_Initial:"\u10ee",F_Fri_Initial:"\u10de",S_Sat_Initial:"\u10e8",January:"\u10d8\u10d0\u10dc\u10d5\u10d0\u10e0\u10d8",February:"\u10d7\u10d4\u10d1\u10d4\u10e0\u10d5\u10d0\u10da\u10d8",March:"\u10db\u10d0\u10e0\u10e2\u10d8",April:"\u10d0\u10de\u10e0\u10d8\u10da\u10d8",May:"\u10db\u10d0\u10d8\u10e1\u10d8",June:"\u10d8\u10d5\u10dc\u10d8\u10e1\u10d8",July:"\u10d8\u10d5\u10da\u10d8\u10e1\u10d8",August:"\u10d0\u10d2\u10d5\u10d8\u10e1\u10e2\u10dd", +September:"\u10e1\u10d4\u10e5\u10e2\u10d4\u10db\u10d1\u10d4\u10e0\u10d8",October:"\u10dd\u10e5\u10e2\u10dd\u10db\u10d1\u10d4\u10e0\u10d8",November:"\u10dc\u10dd\u10d4\u10db\u10d1\u10d4\u10e0\u10d8",December:"\u10d3\u10d4\u10d9\u10d4\u10db\u10d1\u10d4\u10e0\u10d8",Jan_Abbr:"\u10d8\u10d0\u10dc",Feb_Abbr:"\u10d7\u10d4\u10d1",Mar_Abbr:"\u10db\u10d0\u10e0",Apr_Abbr:"\u10d0\u10de\u10e0",May_Abbr:"\u10db\u10d0\u10d8\u10e1",Jun_Abbr:"\u10d8\u10d5\u10dc",Jul_Abbr:"\u10d8\u10d5\u10da",Aug_Abbr:"\u10d0\u10d2\u10d5", +Sep_Abbr:"\u10e1\u10d4\u10e5",Oct_Abbr:"\u10dd\u10e5\u10e2",Nov_Abbr:"\u10dc\u10dd\u10d4\u10db",Dec_Abbr:"\u10d3\u10d4\u10d9",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yyyy","dddd, MMMM dd, yyyy":"yyyy '\u10ec\u10da\u10d8\u10e1' dd MM, dddd","h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy '\u10ec\u10da\u10d8\u10e1' 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)?/":"\u10d8\u10d0\u10dc(\u10d5\u10d0\u10e0\u10d8)?","/feb(ruary)?/":"\u10d7\u10d4\u10d1(\u10d4\u10e0\u10d5\u10d0\u10da\u10d8)?","/mar(ch)?/":"\u10db\u10d0\u10e0(\u10e2\u10d8)?","/apr(il)?/":"\u10d0\u10de\u10e0(\u10d8\u10da\u10d8)?","/may/":"\u10db\u10d0\u10d8\u10e1(\u10d8)?","/jun(e)?/":"\u10d8\u10d5\u10dc(\u10d8\u10e1\u10d8)?","/jul(y)?/":"\u10d8\u10d5\u10da(\u10d8\u10e1\u10d8)?","/aug(ust)?/":"\u10d0\u10d2\u10d5(\u10d8\u10e1\u10e2\u10dd)?","/sep(t(ember)?)?/":"\u10e1\u10d4\u10e5(\u10e2\u10d4\u10db\u10d1\u10d4\u10e0\u10d8)?", +"/oct(ober)?/":"\u10dd\u10e5\u10e2(\u10dd\u10db\u10d1\u10d4\u10e0\u10d8)?","/nov(ember)?/":"\u10dc\u10dd\u10d4\u10db(\u10d1\u10d4\u10e0\u10d8)?","/dec(ember)?/":"\u10d3\u10d4\u10d9(\u10d4\u10db\u10d1\u10d4\u10e0\u10d8)?","/^su(n(day)?)?/":"^\u10d9(1)?","/^mo(n(day)?)?/":"^\u10dd(1)?","/^tu(e(s(day)?)?)?/":"^\u10e1(1)?","/^we(d(nesday)?)?/":"^\u10dd(1)?","/^th(u(r(s(day)?)?)?)?/":"^\u10ee(1)?","/^fr(i(day)?)?/":"^\u10de(1)?","/^sa(t(urday)?)?/":"^\u10e8(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["kk-KZ"]={name:"kk-KZ",englishName:"Kazakh (Kazakhstan)",nativeName:"\u049a\u0430\u0437\u0430\u049b (\u049a\u0430\u0437\u0430\u049b\u0441\u0442\u0430\u043d)",Sunday:"\u0416\u0435\u043a\u0441\u0435\u043d\u0431\u0456",Monday:"\u0414\u04af\u0439\u0441\u0435\u043d\u0431\u0456",Tuesday:"\u0421\u0435\u0439\u0441\u0435\u043d\u0431\u0456",Wednesday:"\u0421\u04d9\u0440\u0441\u0435\u043d\u0431\u0456",Thursday:"\u0411\u0435\u0439\u0441\u0435\u043d\u0431\u0456",Friday:"\u0416\u04b1\u043c\u0430", +Saturday:"\u0421\u0435\u043d\u0431\u0456",Sun:"\u0416\u043a",Mon:"\u0414\u0441",Tue:"\u0421\u0441",Wed:"\u0421\u0440",Thu:"\u0411\u0441",Fri:"\u0416\u043c",Sat:"\u0421\u043d",Su:"\u0416\u043a",Mo:"\u0414\u0441",Tu:"\u0421\u0441",We:"\u0421\u0440",Th:"\u0411\u0441",Fr:"\u0416\u043c",Sa:"\u0421\u043d",S_Sun_Initial:"\u0416",M_Mon_Initial:"\u0414",T_Tue_Initial:"\u0421",W_Wed_Initial:"\u0421",T_Thu_Initial:"\u0411",F_Fri_Initial:"\u0416",S_Sat_Initial:"\u0421",January:"\u049b\u0430\u04a3\u0442\u0430\u0440", +February:"\u0430\u049b\u043f\u0430\u043d",March:"\u043d\u0430\u0443\u0440\u044b\u0437",April:"\u0441\u04d9\u0443\u0456\u0440",May:"\u043c\u0430\u043c\u044b\u0440",June:"\u043c\u0430\u0443\u0441\u044b\u043c",July:"\u0448\u0456\u043b\u0434\u0435",August:"\u0442\u0430\u043c\u044b\u0437",September:"\u049b\u044b\u0440\u043a\u04af\u0439\u0435\u043a",October:"\u049b\u0430\u0437\u0430\u043d",November:"\u049b\u0430\u0440\u0430\u0448\u0430",December:"\u0436\u0435\u043b\u0442\u043e\u049b\u0441\u0430\u043d", +Jan_Abbr:"\u049a\u0430\u04a3",Feb_Abbr:"\u0410\u049b\u043f",Mar_Abbr:"\u041d\u0430\u0443",Apr_Abbr:"\u0421\u04d9\u0443",May_Abbr:"\u041c\u0430\u043c",Jun_Abbr:"\u041c\u0430\u0443",Jul_Abbr:"\u0428\u0456\u043b",Aug_Abbr:"\u0422\u0430\u043c",Sep_Abbr:"\u049a\u044b\u0440",Oct_Abbr:"\u049a\u0430\u0437",Nov_Abbr:"\u049a\u0430\u0440",Dec_Abbr:"\u0416\u0435\u043b",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yyyy","dddd, MMMM dd, yyyy":"d MMMM yyyy '\u0436.'","h:mm tt":"H:mm", +"h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"d MMMM yyyy '\u0436.' 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)?/":"\u049b\u0430\u04a3(\u0442\u0430\u0440)?","/feb(ruary)?/":"\u0430\u049b\u043f(\u0430\u043d)?","/mar(ch)?/":"\u043d\u0430\u0443(\u0440\u044b\u0437)?","/apr(il)?/":"\u0441\u04d9\u0443(\u0456\u0440)?","/may/":"\u043c\u0430\u043c(\u044b\u0440)?", +"/jun(e)?/":"\u043c\u0430\u0443(\u0441\u044b\u043c)?","/jul(y)?/":"\u0448\u0456\u043b(\u0434\u0435)?","/aug(ust)?/":"\u0442\u0430\u043c(\u044b\u0437)?","/sep(t(ember)?)?/":"\u049b\u044b\u0440(\u043a\u04af\u0439\u0435\u043a)?","/oct(ober)?/":"\u049b\u0430\u0437(\u0430\u043d)?","/nov(ember)?/":"\u049b\u0430\u0440(\u0430\u0448\u0430)?","/dec(ember)?/":"\u0436\u0435\u043b(\u0442\u043e\u049b\u0441\u0430\u043d)?","/^su(n(day)?)?/":"^\u0436\u0435\u043a\u0441\u0435\u043d\u0431\u0456","/^mo(n(day)?)?/":"^\u0434\u04af\u0439\u0441\u0435\u043d\u0431\u0456", +"/^tu(e(s(day)?)?)?/":"^\u0441\u0435\u0439\u0441\u0435\u043d\u0431\u0456","/^we(d(nesday)?)?/":"^\u0441\u04d9\u0440\u0441\u0435\u043d\u0431\u0456","/^th(u(r(s(day)?)?)?)?/":"^\u0431\u0435\u0439\u0441\u0435\u043d\u0431\u0456","/^fr(i(day)?)?/":"^\u0436\u04b1\u043c\u0430","/^sa(t(urday)?)?/":"^\u0441\u0435\u043d\u0431\u0456","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["kn-IN"]={name:"kn-IN",englishName:"Kannada (India)",nativeName:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1 (\u0cad\u0cbe\u0cb0\u0ca4)",Sunday:"\u0cad\u0cbe\u0ca8\u0cc1\u0cb5\u0cbe\u0cb0",Monday:"\u0cb8\u0ccb\u0cae\u0cb5\u0cbe\u0cb0",Tuesday:"\u0cae\u0c82\u0c97\u0cb3\u0cb5\u0cbe\u0cb0",Wednesday:"\u0cac\u0cc1\u0ca7\u0cb5\u0cbe\u0cb0",Thursday:"\u0c97\u0cc1\u0cb0\u0cc1\u0cb5\u0cbe\u0cb0",Friday:"\u0cb6\u0cc1\u0c95\u0ccd\u0cb0\u0cb5\u0cbe\u0cb0",Saturday:"\u0cb6\u0ca8\u0cbf\u0cb5\u0cbe\u0cb0",Sun:"\u0cad\u0cbe\u0ca8\u0cc1.", +Mon:"\u0cb8\u0ccb\u0cae.",Tue:"\u0cae\u0c82\u0c97\u0cb3.",Wed:"\u0cac\u0cc1\u0ca7.",Thu:"\u0c97\u0cc1\u0cb0\u0cc1.",Fri:"\u0cb6\u0cc1\u0c95\u0ccd\u0cb0.",Sat:"\u0cb6\u0ca8\u0cbf.",Su:"\u0cb0",Mo:"\u0cb8",Tu:"\u0cae",We:"\u0cac",Th:"\u0c97",Fr:"\u0cb6",Sa:"\u0cb6",S_Sun_Initial:"\u0cb0",M_Mon_Initial:"\u0cb8",T_Tue_Initial:"\u0cae",W_Wed_Initial:"\u0cac",T_Thu_Initial:"\u0c97",F_Fri_Initial:"\u0cb6",S_Sat_Initial:"\u0cb6",January:"\u0c9c\u0ca8\u0cb5\u0cb0\u0cbf",February:"\u0cab\u0cc6\u0cac\u0ccd\u0cb0\u0cb5\u0cb0\u0cbf", +March:"\u0cae\u0cbe\u0cb0\u0ccd\u0c9a\u0ccd",April:"\u0c8e\u0caa\u0ccd\u0cb0\u0cbf\u0cb2\u0ccd",May:"\u0cae\u0cc7",June:"\u0c9c\u0cc2\u0ca8\u0ccd",July:"\u0c9c\u0cc1\u0cb2\u0cc8",August:"\u0c86\u0c97\u0cb8\u0ccd\u0c9f\u0ccd",September:"\u0cb8\u0cc6\u0caa\u0ccd\u0c9f\u0c82\u0cac\u0cb0\u0ccd",October:"\u0c85\u0c95\u0ccd\u0c9f\u0ccb\u0cac\u0cb0\u0ccd",November:"\u0ca8\u0cb5\u0cc6\u0c82\u0cac\u0cb0\u0ccd",December:"\u0ca1\u0cbf\u0cb8\u0cc6\u0c82\u0cac\u0cb0\u0ccd",Jan_Abbr:"\u0c9c\u0ca8\u0cb5\u0cb0\u0cbf", +Feb_Abbr:"\u0cab\u0cc6\u0cac\u0ccd\u0cb0\u0cb5\u0cb0\u0cbf",Mar_Abbr:"\u0cae\u0cbe\u0cb0\u0ccd\u0c9a\u0ccd",Apr_Abbr:"\u0c8e\u0caa\u0ccd\u0cb0\u0cbf\u0cb2\u0ccd",May_Abbr:"\u0cae\u0cc7",Jun_Abbr:"\u0c9c\u0cc2\u0ca8\u0ccd",Jul_Abbr:"\u0c9c\u0cc1\u0cb2\u0cc8",Aug_Abbr:"\u0c86\u0c97\u0cb8\u0ccd\u0c9f\u0ccd",Sep_Abbr:"\u0cb8\u0cc6\u0caa\u0ccd\u0c9f\u0c82\u0cac\u0cb0\u0ccd",Oct_Abbr:"\u0c85\u0c95\u0ccd\u0c9f\u0ccb\u0cac\u0cb0\u0ccd",Nov_Abbr:"\u0ca8\u0cb5\u0cc6\u0c82\u0cac\u0cb0\u0ccd",Dec_Abbr:"\u0ca1\u0cbf\u0cb8\u0cc6\u0c82\u0cac\u0cb0\u0ccd", +AM:"\u0caa\u0cc2\u0cb0\u0ccd\u0cb5\u0cbe\u0cb9\u0ccd\u0ca8",PM:"\u0c85\u0caa\u0cb0\u0cbe\u0cb9\u0ccd\u0ca8",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)?/":"\u0c9c\u0ca8\u0cb5\u0cb0\u0cbf","/feb(ruary)?/":"\u0cab\u0cc6\u0cac\u0ccd\u0cb0\u0cb5\u0cb0\u0cbf","/mar(ch)?/":"\u0cae\u0cbe\u0cb0\u0ccd\u0c9a\u0ccd","/apr(il)?/":"\u0c8e\u0caa\u0ccd\u0cb0\u0cbf\u0cb2\u0ccd","/may/":"\u0cae\u0cc7","/jun(e)?/":"\u0c9c\u0cc2\u0ca8\u0ccd","/jul(y)?/":"\u0c9c\u0cc1\u0cb2\u0cc8","/aug(ust)?/":"\u0c86\u0c97\u0cb8\u0ccd\u0c9f\u0ccd","/sep(t(ember)?)?/":"\u0cb8\u0cc6\u0caa\u0ccd\u0c9f\u0c82\u0cac\u0cb0\u0ccd","/oct(ober)?/":"\u0c85\u0c95\u0ccd\u0c9f\u0ccb\u0cac\u0cb0\u0ccd", +"/nov(ember)?/":"\u0ca8\u0cb5\u0cc6\u0c82\u0cac\u0cb0\u0ccd","/dec(ember)?/":"\u0ca1\u0cbf\u0cb8\u0cc6\u0c82\u0cac\u0cb0\u0ccd","/^su(n(day)?)?/":"^\u0cb0(\u0cbe\u0ca8\u0cc1(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^mo(n(day)?)?/":"^\u0cb8(\u0ccb\u0cae(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^tu(e(s(day)?)?)?/":"^\u0cae(\u0c82\u0c97\u0cb3(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^we(d(nesday)?)?/":"^\u0cac(\u0cc1\u0ca7(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0c97(\u0cc1\u0cb0\u0cc1(.(\u0cb5\u0cbe\u0cb0)?)?)?", +"/^fr(i(day)?)?/":"^\u0cb6(\u0cc1\u0c95\u0ccd\u0cb0(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^sa(t(urday)?)?/":"^\u0cb6(\u0ca8\u0cbf(.(\u0cb5\u0cbe\u0cb0)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?", +"/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)", +LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ko-KR"]={name:"ko-KR",englishName:"Korean (Korea)",nativeName:"\ud55c\uad6d\uc5b4 (\ub300\ud55c\ubbfc\uad6d)",Sunday:"\uc77c\uc694\uc77c",Monday:"\uc6d4\uc694\uc77c",Tuesday:"\ud654\uc694\uc77c",Wednesday:"\uc218\uc694\uc77c",Thursday:"\ubaa9\uc694\uc77c",Friday:"\uae08\uc694\uc77c",Saturday:"\ud1a0\uc694\uc77c",Sun:"\uc77c",Mon:"\uc6d4",Tue:"\ud654",Wed:"\uc218",Thu:"\ubaa9",Fri:"\uae08",Sat:"\ud1a0",Su:"\uc77c",Mo:"\uc6d4",Tu:"\ud654",We:"\uc218",Th:"\ubaa9",Fr:"\uae08",Sa:"\ud1a0", +S_Sun_Initial:"\uc77c",M_Mon_Initial:"\uc6d4",T_Tue_Initial:"\ud654",W_Wed_Initial:"\uc218",T_Thu_Initial:"\ubaa9",F_Fri_Initial:"\uae08",S_Sat_Initial:"\ud1a0",January:"1\uc6d4",February:"2\uc6d4",March:"3\uc6d4",April:"4\uc6d4",May:"5\uc6d4",June:"6\uc6d4",July:"7\uc6d4",August:"8\uc6d4",September:"9\uc6d4",October:"10\uc6d4",November:"11\uc6d4",December:"12\uc6d4",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:"\uc624\uc804",PM:"\uc624\ud6c4",firstDayOfWeek:0,twoDigitYearMax:2029,mdy:"ymd","M/d/yyyy":"yyyy-MM-dd","dddd, MMMM dd, yyyy":"yyyy'\ub144' M'\uc6d4' d'\uc77c' dddd","h:mm tt":"tt h:mm","h:mm:ss tt":"tt h:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy'\ub144' M'\uc6d4' d'\uc77c' 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'\uc6d4' d'\uc77c'", +"MMMM, yyyy":"yyyy'\ub144' M'\uc6d4'","/jan(uary)?/":"1(\uc6d4)?","/feb(ruary)?/":"2(\uc6d4)?","/mar(ch)?/":"3(\uc6d4)?","/apr(il)?/":"4(\uc6d4)?","/may/":"5(\uc6d4)?","/jun(e)?/":"6(\uc6d4)?","/jul(y)?/":"7(\uc6d4)?","/aug(ust)?/":"8(\uc6d4)?","/sep(t(ember)?)?/":"9(\uc6d4)?","/oct(ober)?/":"10(\uc6d4)?","/nov(ember)?/":"11(\uc6d4)?","/dec(ember)?/":"12(\uc6d4)?","/^su(n(day)?)?/":"^\uc77c\uc694\uc77c","/^mo(n(day)?)?/":"^\uc6d4\uc694\uc77c","/^tu(e(s(day)?)?)?/":"^\ud654\uc694\uc77c","/^we(d(nesday)?)?/":"^\uc218\uc694\uc77c", +"/^th(u(r(s(day)?)?)?)?/":"^\ubaa9\uc694\uc77c","/^fr(i(day)?)?/":"^\uae08\uc694\uc77c","/^sa(t(urday)?)?/":"^\ud1a0\uc694\uc77c","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?", +"/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)", +LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["kok-IN"]={name:"kok-IN",englishName:"Konkani (India)",nativeName:"\u0915\u094b\u0902\u0915\u0923\u0940 (\u092d\u093e\u0930\u0924)",Sunday:"\u0906\u092f\u0924\u093e\u0930",Monday:"\u0938\u094b\u092e\u093e\u0930",Tuesday:"\u092e\u0902\u0917\u0933\u093e\u0930",Wednesday:"\u092c\u0941\u0927\u0935\u093e\u0930",Thursday:"\u092c\u093f\u0930\u0947\u0938\u094d\u0924\u093e\u0930",Friday:"\u0938\u0941\u0915\u094d\u0930\u093e\u0930",Saturday:"\u0936\u0947\u0928\u0935\u093e\u0930",Sun:"\u0906\u092f.", +Mon:"\u0938\u094b\u092e.",Tue:"\u092e\u0902\u0917\u0933.",Wed:"\u092c\u0941\u0927.",Thu:"\u092c\u093f\u0930\u0947.",Fri:"\u0938\u0941\u0915\u094d\u0930.",Sat:"\u0936\u0947\u0928.",Su:"\u0906",Mo:"\u0938",Tu:"\u092e",We:"\u092c",Th:"\u092c",Fr:"\u0938",Sa:"\u0936",S_Sun_Initial:"\u0906",M_Mon_Initial:"\u0938",T_Tue_Initial:"\u092e",W_Wed_Initial:"\u092c",T_Thu_Initial:"\u092c",F_Fri_Initial:"\u0938",S_Sat_Initial:"\u0936",January:"\u091c\u093e\u0928\u0947\u0935\u093e\u0930\u0940",February:"\u092b\u0947\u092c\u094d\u0930\u0941\u0935\u093e\u0930\u0940", +March:"\u092e\u093e\u0930\u094d\u091a",April:"\u090f\u092a\u094d\u0930\u093f\u0932",May:"\u092e\u0947",June:"\u091c\u0942\u0928",July:"\u091c\u0941\u0932\u0948",August:"\u0911\u0917\u0938\u094d\u091f",September:"\u0938\u092a\u094d\u091f\u0947\u0902\u092c\u0930",October:"\u0911\u0915\u094d\u091f\u094b\u092c\u0930",November:"\u0928\u094b\u0935\u0947\u092e\u094d\u092c\u0930",December:"\u0921\u093f\u0938\u0947\u0902\u092c\u0930",Jan_Abbr:"\u091c\u093e\u0928\u0947\u0935\u093e\u0930\u0940",Feb_Abbr:"\u092b\u0947\u092c\u094d\u0930\u0941\u0935\u093e\u0930\u0940", +Mar_Abbr:"\u092e\u093e\u0930\u094d\u091a",Apr_Abbr:"\u090f\u092a\u094d\u0930\u093f\u0932",May_Abbr:"\u092e\u0947",Jun_Abbr:"\u091c\u0942\u0928",Jul_Abbr:"\u091c\u0941\u0932\u0948",Aug_Abbr:"\u0911\u0917\u0938\u094d\u091f",Sep_Abbr:"\u0938\u092a\u094d\u091f\u0947\u0902\u092c\u0930",Oct_Abbr:"\u0911\u0915\u094d\u091f\u094b\u092c\u0930",Nov_Abbr:"\u0928\u094b\u0935\u0947\u092e\u094d\u092c\u0930",Dec_Abbr:"\u0921\u093f\u0938\u0947\u0902\u092c\u0930",AM:"\u092e.\u092a\u0942.",PM:"\u092e.\u0928\u0902.", +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)?/":"\u091c\u093e\u0928\u0947\u0935\u093e\u0930\u0940","/feb(ruary)?/":"\u092b\u0947\u092c\u094d\u0930\u0941\u0935\u093e\u0930\u0940", +"/mar(ch)?/":"\u092e\u093e\u0930\u094d\u091a","/apr(il)?/":"\u090f\u092a\u094d\u0930\u093f\u0932","/may/":"\u092e\u0947","/jun(e)?/":"\u091c\u0942\u0928","/jul(y)?/":"\u091c\u0941\u0932\u0948","/aug(ust)?/":"\u0911\u0917\u0938\u094d\u091f","/sep(t(ember)?)?/":"\u0938\u092a\u094d\u091f\u0947\u0902\u092c\u0930","/oct(ober)?/":"\u0911\u0915\u094d\u091f\u094b\u092c\u0930","/nov(ember)?/":"\u0928\u094b\u0935\u0947\u092e\u094d\u092c\u0930","/dec(ember)?/":"\u0921\u093f\u0938\u0947\u0902\u092c\u0930","/^su(n(day)?)?/":"^\u0906(\u092f(.(\u0924\u093e\u0930)?)?)?", +"/^mo(n(day)?)?/":"^\u0938(\u094b\u092e(.(\u093e\u0930)?)?)?","/^tu(e(s(day)?)?)?/":"^\u092e(\u0902\u0917\u0933(.(\u093e\u0930)?)?)?","/^we(d(nesday)?)?/":"^\u092c(\u0941\u0927(.(\u0935\u093e\u0930)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u092c(\u093f\u0930\u0947(.(\u0938\u094d\u0924\u093e\u0930)?)?)?","/^fr(i(day)?)?/":"^\u0938(\u0941\u0915\u094d\u0930(.(\u093e\u0930)?)?)?","/^sa(t(urday)?)?/":"^\u0936(\u0947\u0928(.(\u0935\u093e\u0930)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ky-KG"]={name:"ky-KG",englishName:"Kyrgyz (Kyrgyzstan)",nativeName:"\u041a\u044b\u0440\u0433\u044b\u0437 (\u041a\u044b\u0440\u0433\u044b\u0437\u0441\u0442\u0430\u043d)",Sunday:"\u0416\u0435\u043a\u0448\u0435\u043c\u0431\u0438",Monday:"\u0414\u04af\u0439\u0448\u04e9\u043c\u0431\u04af",Tuesday:"\u0428\u0435\u0439\u0448\u0435\u043c\u0431\u0438",Wednesday:"\u0428\u0430\u0440\u0448\u0435\u043c\u0431\u0438",Thursday:"\u0411\u0435\u0439\u0448\u0435\u043c\u0431\u0438",Friday:"\u0416\u0443\u043c\u0430", +Saturday:"\u0418\u0448\u0435\u043c\u0431\u0438",Sun:"\u0416\u0448",Mon:"\u0414\u0448",Tue:"\u0428\u0448",Wed:"\u0428\u0440",Thu:"\u0411\u0448",Fri:"\u0416\u043c",Sat:"\u0418\u0448",Su:"\u0416\u0448",Mo:"\u0414\u0448",Tu:"\u0428\u0448",We:"\u0428\u0440",Th:"\u0411\u0448",Fr:"\u0416\u043c",Sa:"\u0418\u0448",S_Sun_Initial:"\u0416",M_Mon_Initial:"\u0414",T_Tue_Initial:"\u0428",W_Wed_Initial:"\u0428",T_Thu_Initial:"\u0411",F_Fri_Initial:"\u0416",S_Sat_Initial:"\u0418",January:"\u042f\u043d\u0432\u0430\u0440\u044c", +February:"\u0424\u0435\u0432\u0440\u0430\u043b\u044c",March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0435\u043b\u044c",May:"\u041c\u0430\u0439",June:"\u0418\u044e\u043d\u044c",July:"\u0418\u044e\u043b\u044c",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c",October:"\u041e\u043a\u0442\u044f\u0431\u0440\u044c",November:"\u041d\u043e\u044f\u0431\u0440\u044c",December:"\u0414\u0435\u043a\u0430\u0431\u0440\u044c",Jan_Abbr:"\u042f\u043d\u0432", +Feb_Abbr:"\u0424\u0435\u0432",Mar_Abbr:"\u041c\u0430\u0440",Apr_Abbr:"\u0410\u043f\u0440",May_Abbr:"\u041c\u0430\u0439",Jun_Abbr:"\u0418\u044e\u043d",Jul_Abbr:"\u0418\u044e\u043b",Aug_Abbr:"\u0410\u0432\u0433",Sep_Abbr:"\u0421\u0435\u043d",Oct_Abbr:"\u041e\u043a\u0442",Nov_Abbr:"\u041d\u043e\u044f",Dec_Abbr:"\u0414\u0435\u043a",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yy","dddd, MMMM dd, yyyy":"d'-'MMMM yyyy'-\u0436.'","h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"d'-'MMMM yyyy'-\u0436.' 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'-\u0436.'","/jan(uary)?/":"\u044f\u043d\u0432(\u0430\u0440\u044c)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0430\u043b\u044c)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0435\u043b\u044c)?","/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u0438\u044e\u043d(\u044c)?","/jul(y)?/":"\u0438\u044e\u043b(\u044c)?", +"/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043d(\u0442\u044f\u0431\u0440\u044c)?","/oct(ober)?/":"\u043e\u043a\u0442(\u044f\u0431\u0440\u044c)?","/nov(ember)?/":"\u043d\u043e\u044f(\u0431\u0440\u044c)?","/dec(ember)?/":"\u0434\u0435\u043a(\u0430\u0431\u0440\u044c)?","/^su(n(day)?)?/":"^\u0436\u0435\u043a\u0448\u0435\u043c\u0431\u0438","/^mo(n(day)?)?/":"^\u0434\u04af\u0439\u0448\u04e9\u043c\u0431\u04af","/^tu(e(s(day)?)?)?/":"^\u0448\u0435\u0439\u0448\u0435\u043c\u0431\u0438", +"/^we(d(nesday)?)?/":"^\u0448\u0430\u0440\u0448\u0435\u043c\u0431\u0438","/^th(u(r(s(day)?)?)?)?/":"^\u0431\u0435\u0439\u0448\u0435\u043c\u0431\u0438","/^fr(i(day)?)?/":"^\u0436\u0443\u043c\u0430","/^sa(t(urday)?)?/":"^\u0438\u0448\u0435\u043c\u0431\u0438","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["lt-LT"]={name:"lt-LT",englishName:"Lithuanian (Lithuania)",nativeName:"lietuvi\u0173 (Lietuva)",Sunday:"sekmadienis",Monday:"pirmadienis",Tuesday:"antradienis",Wednesday:"tre\u010diadienis",Thursday:"ketvirtadienis",Friday:"penktadienis",Saturday:"\u0161e\u0161tadienis",Sun:"Sk",Mon:"Pr",Tue:"An",Wed:"Tr",Thu:"Kt",Fri:"Pn",Sat:"\u0160t",Su:"S",Mo:"P",Tu:"A",We:"T",Th:"K",Fr:"Pn",Sa:"\u0160",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:"\u0160",January:"sausis",February:"vasaris",March:"kovas",April:"balandis",May:"gegu\u017e\u0117",June:"bir\u017eelis",July:"liepa",August:"rugpj\u016btis",September:"rugs\u0117jis",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\u017e\u0117)?", +"/jun(e)?/":"bir(\u017eelis)?","/jul(y)?/":"lie(pa)?","/aug(ust)?/":"rugpj\u016btis","/sep(t(ember)?)?/":"rugs\u0117jis","/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\u010diadienis)?)?","/^th(u(r(s(day)?)?)?)?/":"^k(t(tvirtadienis)?)?","/^fr(i(day)?)?/":"^penktadienis","/^sa(t(urday)?)?/":"^\u0161(t(\u0161tadienis)?)?", +"/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?", +"/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST", +CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["lv-LV"]={name:"lv-LV",englishName:"Latvian (Latvia)",nativeName:"latvie\u0161u (Latvija)",Sunday:"sv\u0113tdiena",Monday:"pirmdiena",Tuesday:"otrdiena",Wednesday:"tre\u0161diena",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\u0101ris",February:"febru\u0101ris",March:"marts",April:"apr\u012blis",May:"maijs",June:"j\u016bnijs",July:"j\u016blijs",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\u016bn",Jul_Abbr:"J\u016bl",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\u0101ris)?","/feb(ruary)?/":"feb(ru\u0101ris)?","/mar(ch)?/":"mar(ts)?","/apr(il)?/":"apr(\u012blis)?","/may/":"mai(js)?","/jun(e)?/":"j\u016bn(ijs)?", +"/jul(y)?/":"j\u016bl(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\u0113tdiena","/^mo(n(day)?)?/":"^pirmdiena","/^tu(e(s(day)?)?)?/":"^otrdiena","/^we(d(nesday)?)?/":"^tre\u0161diena","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["mi-NZ"]={name:"mi-NZ",englishName:"Maori (New Zealand)",nativeName:"Reo M\u0101ori (Aotearoa)",Sunday:"R\u0101tapu",Monday:"Mane",Tuesday:"T\u016brei",Wednesday:"Wenerei",Thursday:"T\u0101ite",Friday:"Paraire",Saturday:"H\u0101tarei",Sun:"Ta",Mon:"Ma",Tue:"T\u016b",Wed:"We",Thu:"T\u0101i",Fri:"Pa",Sat:"H\u0101",Su:"Ta",Mo:"Ma",Tu:"T\u016b",We:"We",Th:"T\u0101i",Fr:"Pa",Sa:"H\u0101",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\u0101tea",February:"Hui-tanguru",March:"Pout\u016b-te-rangi",April:"Paenga-wh\u0101wh\u0101",May:"Haratua",June:"Pipiri",July:"H\u014dngoingoi",August:"Here-turi-k\u014dk\u0101",September:"Mahuru",October:"Whiringa-\u0101-nuku",November:"Whiringa-\u0101-rangi",December:"Hakihea",Jan_Abbr:"Kohi",Feb_Abbr:"Hui",Mar_Abbr:"Pou",Apr_Abbr:"Pae",May_Abbr:"Hara",Jun_Abbr:"Pipi",Jul_Abbr:"H\u014dngoi",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\u0101tea)?","/feb(ruary)?/":"hui(-tanguru)?", +"/mar(ch)?/":"pou(t\u016b-te-rangi)?","/apr(il)?/":"pae(nga-wh\u0101wh\u0101)?","/may/":"hara(tua)?","/jun(e)?/":"pipi(ri)?","/jul(y)?/":"h\u014dngoi(ngoi)?","/aug(ust)?/":"here(-turi-k\u014dk\u0101)?","/sep(t(ember)?)?/":"mahu(ru)?","/oct(ober)?/":"whiringa-\u0101-nuku","/nov(ember)?/":"whiringa-\u0101-rangi","/dec(ember)?/":"haki(hea)?","/^su(n(day)?)?/":"^r\u0101tapu","/^mo(n(day)?)?/":"^mane","/^tu(e(s(day)?)?)?/":"^t\u016brei","/^we(d(nesday)?)?/":"^wenerei","/^th(u(r(s(day)?)?)?)?/":"^t\u0101ite", +"/^fr(i(day)?)?/":"^paraire","/^sa(t(urday)?)?/":"^h\u0101tarei","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?", +"/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST", +NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["mk-MK"]={name:"mk-MK",englishName:"Macedonian (Former Yugoslav Republic of Macedonia)",nativeName:"\u043c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 \u0458\u0430\u0437\u0438\u043a (\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0438\u0458\u0430)",Sunday:"\u043d\u0435\u0434\u0435\u043b\u0430",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u043d\u0438\u043a",Tuesday:"\u0432\u0442\u043e\u0440\u043d\u0438\u043a",Wednesday:"\u0441\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0440\u0442\u043e\u043a", +Friday:"\u043f\u0435\u0442\u043e\u043a",Saturday:"\u0441\u0430\u0431\u043e\u0442\u0430",Sun:"\u043d\u0435\u0434",Mon:"\u043f\u043e\u043d",Tue:"\u0432\u0442\u0440",Wed:"\u0441\u0440\u0434",Thu:"\u0447\u0435\u0442",Fri:"\u043f\u0435\u0442",Sat:"\u0441\u0430\u0431",Su:"\u043d\u0435",Mo:"\u043f\u043e",Tu:"\u0432\u0442",We:"\u0441\u0440",Th:"\u0447\u0435",Fr:"\u043f\u0435",Sa:"\u0441\u0430",S_Sun_Initial:"\u043d",M_Mon_Initial:"\u043f",T_Tue_Initial:"\u0432",W_Wed_Initial:"\u0441",T_Thu_Initial:"\u0447", +F_Fri_Initial:"\u043f",S_Sat_Initial:"\u0441",January:"\u0458\u0430\u043d\u0443\u0430\u0440\u0438",February:"\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438",March:"\u043c\u0430\u0440\u0442",April:"\u0430\u043f\u0440\u0438\u043b",May:"\u043c\u0430\u0458",June:"\u0458\u0443\u043d\u0438",July:"\u0458\u0443\u043b\u0438",August:"\u0430\u0432\u0433\u0443\u0441\u0442",September:"\u0441\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438",October:"\u043e\u043a\u0442\u043e\u043c\u0432\u0440\u0438",November:"\u043d\u043e\u0435\u043c\u0432\u0440\u0438", +December:"\u0434\u0435\u043a\u0435\u043c\u0432\u0440\u0438",Jan_Abbr:"\u0458\u0430\u043d",Feb_Abbr:"\u0444\u0435\u0432",Mar_Abbr:"\u043c\u0430\u0440",Apr_Abbr:"\u0430\u043f\u0440",May_Abbr:"\u043c\u0430\u0458",Jun_Abbr:"\u0458\u0443\u043d",Jul_Abbr:"\u0458\u0443\u043b",Aug_Abbr:"\u0430\u0432\u0433",Sep_Abbr:"\u0441\u0435\u043f",Oct_Abbr:"\u043e\u043a\u0442",Nov_Abbr:"\u043d\u043e\u0435",Dec_Abbr:"\u0434\u0435\u043a",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)?/":"\u0458\u0430\u043d(\u0443\u0430\u0440\u0438)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0443\u0430\u0440\u0438)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?", +"/apr(il)?/":"\u0430\u043f\u0440(\u0438\u043b)?","/may/":"\u043c\u0430\u0458","/jun(e)?/":"\u0458\u0443\u043d(\u0438)?","/jul(y)?/":"\u0458\u0443\u043b(\u0438)?","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043f(\u0442\u0435\u043c\u0432\u0440\u0438)?","/oct(ober)?/":"\u043e\u043a\u0442(\u043e\u043c\u0432\u0440\u0438)?","/nov(ember)?/":"\u043d\u043e\u0435(\u043c\u0432\u0440\u0438)?","/dec(ember)?/":"\u0434\u0435\u043a(\u0435\u043c\u0432\u0440\u0438)?", +"/^su(n(day)?)?/":"^\u043d\u0435(\u0434(\u0435\u043b\u0430)?)?","/^mo(n(day)?)?/":"^\u043f\u043e(\u043d(\u0435\u0434\u0435\u043b\u043d\u0438\u043a)?)?","/^tu(e(s(day)?)?)?/":"^\u0432\u0442(\u0440(\u0440\u043d\u0438\u043a)?)?","/^we(d(nesday)?)?/":"^\u0441\u0440(\u0434(\u0434\u0430)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435(\u0442(\u0432\u0440\u0442\u043e\u043a)?)?","/^fr(i(day)?)?/":"^\u043f\u0435(\u0442(\u043e\u043a)?)?","/^sa(t(urday)?)?/":"^\u0441\u0430(\u0431(\u043e\u0442\u0430)?)?","/^next/":"^next", +"/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?", +"/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT", +MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["mn-MN"]={name:"mn-MN",englishName:"Mongolian (Cyrillic, Mongolia)",nativeName:"\u041c\u043e\u043d\u0433\u043e\u043b\u00a0\u0445\u044d\u043b (\u041c\u043e\u043d\u0433\u043e\u043b\u00a0\u0443\u043b\u0441)",Sunday:"\u041d\u044f\u043c",Monday:"\u0414\u0430\u0432\u0430\u0430",Tuesday:"\u041c\u044f\u0433\u043c\u0430\u0440",Wednesday:"\u041b\u0445\u0430\u0433\u0432\u0430",Thursday:"\u041f\u04af\u0440\u044d\u0432",Friday:"\u0411\u0430\u0430\u0441\u0430\u043d",Saturday:"\u0411\u044f\u043c\u0431\u0430", +Sun:"\u041d\u044f",Mon:"\u0414\u0430",Tue:"\u041c\u044f",Wed:"\u041b\u0445",Thu:"\u041f\u04af",Fri:"\u0411\u0430",Sat:"\u0411\u044f",Su:"\u041d\u044f",Mo:"\u0414\u0430",Tu:"\u041c\u044f",We:"\u041b\u0445",Th:"\u041f\u04af",Fr:"\u0411\u0430",Sa:"\u0411\u044f",S_Sun_Initial:"\u041d",M_Mon_Initial:"\u0414",T_Tue_Initial:"\u041c",W_Wed_Initial:"\u041b",T_Thu_Initial:"\u041f",F_Fri_Initial:"\u0411",S_Sat_Initial:"\u0411",January:"1\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440",February:"2\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440", +March:"3\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",April:"4\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440",May:"5\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",June:"6\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",July:"7\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",August:"8\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",September:"9\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440", +October:"10\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",November:"11\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440",December:"12\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440",Jan_Abbr:"I",Feb_Abbr:"II",Mar_Abbr:"III",Apr_Abbr:"IV",May_Abbr:"V",Jun_Abbr:"VI",Jul_Abbr:"VII",Aug_Abbr:"V\u0428",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 '\u043e\u043d\u044b' MMMM d", +"h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy '\u043e\u043d\u044b' 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 '\u043e\u043d' MMMM","/jan(uary)?/":"1\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440","/feb(ruary)?/":"2\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/mar(ch)?/":"3\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440", +"/apr(il)?/":"4\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440","/may/":"5\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/jun(e)?/":"6\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/jul(y)?/":"7\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/aug(ust)?/":"8\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/sep(t(ember)?)?/":"9\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440","/oct(ober)?/":"10\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440", +"/nov(ember)?/":"11\u00a0\u0434\u04af\u0433\u044d\u044d\u0440\u00a0\u0441\u0430\u0440","/dec(ember)?/":"12\u00a0\u0434\u0443\u0433\u0430\u0430\u0440\u00a0\u0441\u0430\u0440","/^su(n(day)?)?/":"^\u043d\u044f\u043c","/^mo(n(day)?)?/":"^\u0434\u0430\u0432\u0430\u0430","/^tu(e(s(day)?)?)?/":"^\u043c\u044f\u0433\u043c\u0430\u0440","/^we(d(nesday)?)?/":"^\u043b\u0445\u0430\u0433\u0432\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u043f\u04af\u0440\u044d\u0432","/^fr(i(day)?)?/":"^\u0431\u0430\u0430\u0441\u0430\u043d", +"/^sa(t(urday)?)?/":"^\u0431\u044f\u043c\u0431\u0430","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["mr-IN"]={name:"mr-IN",englishName:"Marathi (India)",nativeName:"\u092e\u0930\u093e\u0920\u0940 (\u092d\u093e\u0930\u0924)",Sunday:"\u0930\u0935\u093f\u0935\u093e\u0930",Monday:"\u0938\u094b\u092e\u0935\u093e\u0930",Tuesday:"\u092e\u0902\u0917\u0933\u0935\u093e\u0930",Wednesday:"\u092c\u0941\u0927\u0935\u093e\u0930",Thursday:"\u0917\u0941\u0930\u0941\u0935\u093e\u0930",Friday:"\u0936\u0941\u0915\u094d\u0930\u0935\u093e\u0930",Saturday:"\u0936\u0928\u093f\u0935\u093e\u0930",Sun:"\u0930\u0935\u093f.", +Mon:"\u0938\u094b\u092e.",Tue:"\u092e\u0902\u0917\u0933.",Wed:"\u092c\u0941\u0927.",Thu:"\u0917\u0941\u0930\u0941.",Fri:"\u0936\u0941\u0915\u094d\u0930.",Sat:"\u0936\u0928\u093f.",Su:"\u0930",Mo:"\u0938",Tu:"\u092e",We:"\u092c",Th:"\u0917",Fr:"\u0936",Sa:"\u0936",S_Sun_Initial:"\u0930",M_Mon_Initial:"\u0938",T_Tue_Initial:"\u092e",W_Wed_Initial:"\u092c",T_Thu_Initial:"\u0917",F_Fri_Initial:"\u0936",S_Sat_Initial:"\u0936",January:"\u091c\u093e\u0928\u0947\u0935\u093e\u0930\u0940",February:"\u092b\u0947\u092c\u094d\u0930\u0941\u0935\u093e\u0930\u0940", +March:"\u092e\u093e\u0930\u094d\u091a",April:"\u090f\u092a\u094d\u0930\u093f\u0932",May:"\u092e\u0947",June:"\u091c\u0942\u0928",July:"\u091c\u0941\u0932\u0948",August:"\u0911\u0917\u0938\u094d\u091f",September:"\u0938\u092a\u094d\u091f\u0947\u0902\u092c\u0930",October:"\u0911\u0915\u094d\u091f\u094b\u092c\u0930",November:"\u0928\u094b\u0935\u094d\u0939\u0947\u0902\u092c\u0930",December:"\u0921\u093f\u0938\u0947\u0902\u092c\u0930",Jan_Abbr:"\u091c\u093e\u0928\u0947.",Feb_Abbr:"\u092b\u0947\u092c\u094d\u0930\u0941.", +Mar_Abbr:"\u092e\u093e\u0930\u094d\u091a",Apr_Abbr:"\u090f\u092a\u094d\u0930\u093f\u0932",May_Abbr:"\u092e\u0947",Jun_Abbr:"\u091c\u0942\u0928",Jul_Abbr:"\u091c\u0941\u0932\u0948",Aug_Abbr:"\u0911\u0917\u0938\u094d\u091f",Sep_Abbr:"\u0938\u092a\u094d\u091f\u0947\u0902.",Oct_Abbr:"\u0911\u0915\u094d\u091f\u094b.",Nov_Abbr:"\u0928\u094b\u0935\u094d\u0939\u0947\u0902.",Dec_Abbr:"\u0921\u093f\u0938\u0947\u0902.",AM:"\u092e.\u092a\u0942.",PM:"\u092e.\u0928\u0902.",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)?/":"\u091c\u093e\u0928\u0947(.(\u0935\u093e\u0930\u0940)?)?","/feb(ruary)?/":"\u092b\u0947\u092c\u094d\u0930\u0941(.(\u0935\u093e\u0930\u0940)?)?", +"/mar(ch)?/":"\u092e\u093e\u0930\u094d\u091a","/apr(il)?/":"\u090f\u092a\u094d\u0930\u093f\u0932","/may/":"\u092e\u0947","/jun(e)?/":"\u091c\u0942\u0928","/jul(y)?/":"\u091c\u0941\u0932\u0948","/aug(ust)?/":"\u0911\u0917\u0938\u094d\u091f","/sep(t(ember)?)?/":"\u0938\u092a\u094d\u091f\u0947\u0902(.(\u092c\u0930)?)?","/oct(ober)?/":"\u0911\u0915\u094d\u091f\u094b(.(\u092c\u0930)?)?","/nov(ember)?/":"\u0928\u094b\u0935\u094d\u0939\u0947\u0902(.(\u092c\u0930)?)?","/dec(ember)?/":"\u0921\u093f\u0938\u0947\u0902(.(\u092c\u0930)?)?", +"/^su(n(day)?)?/":"^\u0930(\u0935\u093f(.(\u0935\u093e\u0930)?)?)?","/^mo(n(day)?)?/":"^\u0938(\u094b\u092e(.(\u0935\u093e\u0930)?)?)?","/^tu(e(s(day)?)?)?/":"^\u092e(\u0902\u0917\u0933(.(\u0935\u093e\u0930)?)?)?","/^we(d(nesday)?)?/":"^\u092c(\u0941\u0927(.(\u0935\u093e\u0930)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0917(\u0941\u0930\u0941(.(\u0935\u093e\u0930)?)?)?","/^fr(i(day)?)?/":"^\u0936(\u0941\u0915\u094d\u0930(.(\u0935\u093e\u0930)?)?)?","/^sa(t(urday)?)?/":"^\u0936(\u0928\u093f(.(\u0935\u093e\u0930)?)?)?", +"/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?", +"/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST", +CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["mt-MT"]={name:"mt-MT",englishName:"Maltese (Malta)",nativeName:"Malti (Malta)",Sunday:"Il-\u0126add",Monday:"It-Tnejn",Tuesday:"It-Tlieta",Wednesday:"L-Erbg\u0127a",Thursday:"Il-\u0126amis",Friday:"Il-\u0120img\u0127a",Saturday:"Is-Sibt",Sun:"\u0126ad",Mon:"Tne",Tue:"Tli",Wed:"Erb",Thu:"\u0126am",Fri:"\u0120im",Sat:"Sib",Su:"\u0126ad",Mo:"Tne",Tu:"Tli",We:"Erb",Th:"\u0126am",Fr:"\u0120im",Sa:"Sib",S_Sun_Initial:"\u0126",M_Mon_Initial:"T",T_Tue_Initial:"T",W_Wed_Initial:"E",T_Thu_Initial:"\u0126", +F_Fri_Initial:"\u0120",S_Sat_Initial:"S",January:"Jannar",February:"Frar",March:"Marzu",April:"April",May:"Mejju",June:"\u0120unju",July:"Lulju",August:"Awissu",September:"Settembru",October:"Ottubru",November:"Novembru",December:"Di\u010bembru",Jan_Abbr:"Jan",Feb_Abbr:"Fra",Mar_Abbr:"Mar",Apr_Abbr:"Apr",May_Abbr:"Mej",Jun_Abbr:"\u0120un",Jul_Abbr:"Lul",Aug_Abbr:"Awi",Sep_Abbr:"Set",Oct_Abbr:"Ott",Nov_Abbr:"Nov",Dec_Abbr:"Di\u010b",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)?/":"\u0121un(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\u010b(embru)?","/^su(n(day)?)?/":"^il-\u0127add","/^mo(n(day)?)?/":"^it-tnejn","/^tu(e(s(day)?)?)?/":"^it-tlieta","/^we(d(nesday)?)?/":"^l-erbg\u0127a","/^th(u(r(s(day)?)?)?)?/":"^il-\u0127amis","/^fr(i(day)?)?/":"^il-\u0121img\u0127a","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["nb-NO"]={name:"nb-NO",englishName:"Norwegian, Bokm\u00e5l (Norway)",nativeName:"norsk, bokm\u00e5l (Norge)",Sunday:"s\u00f8ndag",Monday:"mandag",Tuesday:"tirsdag",Wednesday:"onsdag",Thursday:"torsdag",Friday:"fredag",Saturday:"l\u00f8rdag",Sun:"s\u00f8",Mon:"ma",Tue:"ti",Wed:"on",Thu:"to",Fri:"fr",Sat:"l\u00f8",Su:"s\u00f8",Mo:"ma",Tu:"ti",We:"on",Th:"to",Fr:"fr",Sa:"l\u00f8",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\u00f8ndag","/^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\u00f8rdag","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?", +"/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["nl-BE"]={name:"nl-BE",englishName:"Dutch (Belgium)",nativeName:"Nederlands (Belgi\u00eb)",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["nn-NO"]={name:"nn-NO",englishName:"Norwegian, Nynorsk (Norway)",nativeName:"norsk, nynorsk (Noreg)",Sunday:"s\u00f8ndag",Monday:"m\u00e5ndag",Tuesday:"tysdag",Wednesday:"onsdag",Thursday:"torsdag",Friday:"fredag",Saturday:"laurdag",Sun:"s\u00f8",Mon:"m\u00e5",Tue:"ty",Wed:"on",Thu:"to",Fri:"fr",Sat:"la",Su:"s\u00f8",Mo:"m\u00e5",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\u00f8ndag","/^mo(n(day)?)?/":"^m\u00e5ndag","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u0161upologo",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\u0161ego",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\u0161ego","/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\u0161upologo","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["pa-IN"]={name:"pa-IN",englishName:"Punjabi (India)",nativeName:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40 (\u0a2d\u0a3e\u0a30\u0a24)",Sunday:"\u0a10\u0a24\u0a35\u0a3e\u0a30",Monday:"\u0a38\u0a4b\u0a2e\u0a35\u0a3e\u0a30",Tuesday:"\u0a2e\u0a70\u0a17\u0a32\u0a35\u0a3e\u0a30",Wednesday:"\u0a2c\u0a41\u0a27\u0a35\u0a3e\u0a30",Thursday:"\u0a35\u0a40\u0a30\u0a35\u0a3e\u0a30",Friday:"\u0a36\u0a41\u0a71\u0a15\u0a30\u0a35\u0a3e\u0a30",Saturday:"\u0a36\u0a28\u0a40\u0a1a\u0a30\u0a35\u0a3e\u0a30",Sun:"\u0a10\u0a24.", +Mon:"\u0a38\u0a4b\u0a2e.",Tue:"\u0a2e\u0a70\u0a17\u0a32.",Wed:"\u0a2c\u0a41\u0a27.",Thu:"\u0a35\u0a40\u0a30.",Fri:"\u0a36\u0a41\u0a15\u0a30.",Sat:"\u0a36\u0a28\u0a40.",Su:"\u0a10",Mo:"\u0a38",Tu:"\u0a2e",We:"\u0a2c",Th:"\u0a35",Fr:"\u0a36",Sa:"\u0a36",S_Sun_Initial:"\u0a10",M_Mon_Initial:"\u0a38",T_Tue_Initial:"\u0a2e",W_Wed_Initial:"\u0a2c",T_Thu_Initial:"\u0a35",F_Fri_Initial:"\u0a36",S_Sat_Initial:"\u0a36",January:"\u0a1c\u0a28\u0a35\u0a30\u0a40",February:"\u0a5e\u0a30\u0a35\u0a30\u0a40",March:"\u0a2e\u0a3e\u0a30\u0a1a", +April:"\u0a05\u0a2a\u0a4d\u0a30\u0a48\u0a32",May:"\u0a2e\u0a08",June:"\u0a1c\u0a42\u0a28",July:"\u0a1c\u0a41\u0a32\u0a3e\u0a08",August:"\u0a05\u0a17\u0a38\u0a24",September:"\u0a38\u0a24\u0a70\u0a2c\u0a30",October:"\u0a05\u0a15\u0a24\u0a42\u0a2c\u0a30",November:"\u0a28\u0a35\u0a70\u0a2c\u0a30",December:"\u0a26\u0a38\u0a70\u0a2c\u0a30",Jan_Abbr:"\u0a1c\u0a28\u0a35\u0a30\u0a40",Feb_Abbr:"\u0a5e\u0a30\u0a35\u0a30\u0a40",Mar_Abbr:"\u0a2e\u0a3e\u0a30\u0a1a",Apr_Abbr:"\u0a05\u0a2a\u0a4d\u0a30\u0a48\u0a32", +May_Abbr:"\u0a2e\u0a08",Jun_Abbr:"\u0a1c\u0a42\u0a28",Jul_Abbr:"\u0a1c\u0a41\u0a32\u0a3e\u0a08",Aug_Abbr:"\u0a05\u0a17\u0a38\u0a24",Sep_Abbr:"\u0a38\u0a24\u0a70\u0a2c\u0a30",Oct_Abbr:"\u0a05\u0a15\u0a24\u0a42\u0a2c\u0a30",Nov_Abbr:"\u0a28\u0a35\u0a70\u0a2c\u0a30",Dec_Abbr:"\u0a26\u0a38\u0a70\u0a2c\u0a30",AM:"\u0a38\u0a35\u0a47\u0a30\u0a47",PM:"\u0a36\u0a3e\u0a2e",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)?/":"\u0a1c\u0a28\u0a35\u0a30\u0a40","/feb(ruary)?/":"\u0a5e\u0a30\u0a35\u0a30\u0a40","/mar(ch)?/":"\u0a2e\u0a3e\u0a30\u0a1a","/apr(il)?/":"\u0a05\u0a2a\u0a4d\u0a30\u0a48\u0a32","/may/":"\u0a2e\u0a08","/jun(e)?/":"\u0a1c\u0a42\u0a28", +"/jul(y)?/":"\u0a1c\u0a41\u0a32\u0a3e\u0a08","/aug(ust)?/":"\u0a05\u0a17\u0a38\u0a24","/sep(t(ember)?)?/":"\u0a38\u0a24\u0a70\u0a2c\u0a30","/oct(ober)?/":"\u0a05\u0a15\u0a24\u0a42\u0a2c\u0a30","/nov(ember)?/":"\u0a28\u0a35\u0a70\u0a2c\u0a30","/dec(ember)?/":"\u0a26\u0a38\u0a70\u0a2c\u0a30","/^su(n(day)?)?/":"^\u0a10(\u0a24(.(\u0a35\u0a3e\u0a30)?)?)?","/^mo(n(day)?)?/":"^\u0a38(\u0a4b\u0a2e(.(\u0a35\u0a3e\u0a30)?)?)?","/^tu(e(s(day)?)?)?/":"^\u0a2e(\u0a70\u0a17\u0a32(.(\u0a35\u0a3e\u0a30)?)?)?","/^we(d(nesday)?)?/":"^\u0a2c(\u0a41\u0a27(.(\u0a35\u0a3e\u0a30)?)?)?", +"/^th(u(r(s(day)?)?)?)?/":"^\u0a35(\u0a40\u0a30(.(\u0a35\u0a3e\u0a30)?)?)?","/^fr(i(day)?)?/":"^\u0a36(\u0a41\u0a15\u0a30(.(\u0a30\u0a35\u0a3e\u0a30)?)?)?","/^sa(t(urday)?)?/":"^\u0a36(\u0a28\u0a40(.(\u0a1a\u0a30\u0a35\u0a3e\u0a30)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?", +"/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["pl-PL"]={name:"pl-PL",englishName:"Polish (Poland)",nativeName:"polski (Polska)",Sunday:"niedziela",Monday:"poniedzia\u0142ek",Tuesday:"wtorek",Wednesday:"\u015broda",Thursday:"czwartek",Friday:"pi\u0105tek",Saturday:"sobota",Sun:"N",Mon:"Pn",Tue:"Wt",Wed:"\u015ar",Thu:"Cz",Fri:"Pt",Sat:"So",Su:"N",Mo:"Pn",Tu:"Wt",We:"\u015ar",Th:"Cz",Fr:"Pt",Sa:"So",S_Sun_Initial:"N",M_Mon_Initial:"P",T_Tue_Initial:"W",W_Wed_Initial:"\u015a",T_Thu_Initial:"C",F_Fri_Initial:"P",S_Sat_Initial:"S", +January:"stycze\u0144",February:"luty",March:"marzec",April:"kwiecie\u0144",May:"maj",June:"czerwiec",July:"lipiec",August:"sierpie\u0144",September:"wrzesie\u0144",October:"pa\u017adziernik",November:"listopad",December:"grudzie\u0144",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\u017a",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\u0144)?","/feb(ruary)?/":"lut(y)?","/mar(ch)?/":"mar(zec)?","/apr(il)?/":"kwi(ecie\u0144)?","/may/":"maj","/jun(e)?/":"cze(rwiec)?","/jul(y)?/":"lip(iec)?", +"/aug(ust)?/":"sie(rpie\u0144)?","/sep(t(ember)?)?/":"wrz(esie\u0144)?","/oct(ober)?/":"pa\u017a(dziernik)?","/nov(ember)?/":"lis(topad)?","/dec(ember)?/":"gru(dzie\u0144)?","/^su(n(day)?)?/":"^niedziela","/^mo(n(day)?)?/":"^poniedzia\u0142ek","/^tu(e(s(day)?)?)?/":"^wtorek","/^we(d(nesday)?)?/":"^\u015broda","/^th(u(r(s(day)?)?)?)?/":"^czwartek","/^fr(i(day)?)?/":"^pi\u0105tek","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["pt-BR"]={name:"pt-BR",englishName:"Portuguese (Brazil)",nativeName:"Portugu\u00eas (Brasil)",Sunday:"domingo",Monday:"segunda-feira",Tuesday:"ter\u00e7a-feira",Wednesday:"quarta-feira",Thursday:"quinta-feira",Friday:"sexta-feira",Saturday:"s\u00e1bado",Sun:"dom",Mon:"seg",Tue:"ter",Wed:"qua",Thu:"qui",Fri:"sex",Sat:"s\u00e1b",Su:"dom",Mo:"seg",Tu:"ter",We:"qua",Th:"qui",Fr:"sex",Sa:"s\u00e1b",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\u00e7o",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(\u00e7o)?","/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\u00e7a-feira","/^we(d(nesday)?)?/":"^quarta-feira","/^th(u(r(s(day)?)?)?)?/":"^quinta-feira","/^fr(i(day)?)?/":"^sexta-feira","/^sa(t(urday)?)?/":"^s\u00e1bado","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["pt-PT"]={name:"pt-PT",englishName:"Portuguese (Portugal)",nativeName:"Portugu\u00eas (Portugal)",Sunday:"domingo",Monday:"segunda-feira",Tuesday:"ter\u00e7a-feira",Wednesday:"quarta-feira",Thursday:"quinta-feira",Friday:"sexta-feira",Saturday:"s\u00e1bado",Sun:"dom",Mon:"seg",Tue:"ter",Wed:"qua",Thu:"qui",Fri:"sex",Sat:"s\u00e1b",Su:"dom",Mo:"seg",Tu:"ter",We:"qua",Th:"qui",Fr:"sex",Sa:"s\u00e1b",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\u00e7o",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(\u00e7o)?","/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\u00e7a-feira","/^we(d(nesday)?)?/":"^quarta-feira","/^th(u(r(s(day)?)?)?)?/":"^quinta-feira","/^fr(i(day)?)?/":"^sexta-feira","/^sa(t(urday)?)?/":"^s\u00e1bado","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u0092",Fri:"Ill",Sat:"k'u",Su:"int",Mo:"kil",Tu:"ati",We:"quy",Th:"Ch\u0092",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u0092",Fri:"Ill",Sat:"k'u",Su:"int",Mo:"kil",Tu:"ati",We:"quy",Th:"Ch\u0092",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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\u0092",Fri:"Ill",Sat:"k'u",Su:"int",Mo:"kil",Tu:"ati",We:"quy",Th:"Ch\u0092",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ro-RO"]={name:"ro-RO",englishName:"Romanian (Romania)",nativeName:"rom\u00e2n\u0103 (Rom\u00e2nia)",Sunday:"duminic\u0103",Monday:"luni",Tuesday:"mar\u0163i",Wednesday:"miercuri",Thursday:"joi",Friday:"vineri",Saturday:"s\u00e2mb\u0103t\u0103",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\u0103","/^mo(n(day)?)?/":"^luni","/^tu(e(s(day)?)?)?/":"^mar\u0163i","/^we(d(nesday)?)?/":"^miercuri","/^th(u(r(s(day)?)?)?)?/":"^joi","/^fr(i(day)?)?/":"^vineri","/^sa(t(urday)?)?/":"^s\u00e2mb\u0103t\u0103","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ru-RU"]={name:"ru-RU",englishName:"Russian (Russia)",nativeName:"P\u0443\u0441\u0441\u043a\u0438\u0439 (\u0420\u043e\u0441\u0441\u0438\u044f)",Sunday:"\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a",Tuesday:"\u0432\u0442\u043e\u0440\u043d\u0438\u043a",Wednesday:"\u0441\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0435\u0440\u0433",Friday:"\u043f\u044f\u0442\u043d\u0438\u0446\u0430", +Saturday:"\u0441\u0443\u0431\u0431\u043e\u0442\u0430",Sun:"\u0412\u0441",Mon:"\u041f\u043d",Tue:"\u0412\u0442",Wed:"\u0421\u0440",Thu:"\u0427\u0442",Fri:"\u041f\u0442",Sat:"\u0421\u0431",Su:"\u0412\u0441",Mo:"\u041f\u043d",Tu:"\u0412\u0442",We:"\u0421\u0440",Th:"\u0427\u0442",Fr:"\u041f\u0442",Sa:"\u0421\u0431",S_Sun_Initial:"\u0412",M_Mon_Initial:"\u041f",T_Tue_Initial:"\u0412",W_Wed_Initial:"\u0421",T_Thu_Initial:"\u0427",F_Fri_Initial:"\u041f",S_Sat_Initial:"\u0421",January:"\u042f\u043d\u0432\u0430\u0440\u044c", +February:"\u0424\u0435\u0432\u0440\u0430\u043b\u044c",March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0435\u043b\u044c",May:"\u041c\u0430\u0439",June:"\u0418\u044e\u043d\u044c",July:"\u0418\u044e\u043b\u044c",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c",October:"\u041e\u043a\u0442\u044f\u0431\u0440\u044c",November:"\u041d\u043e\u044f\u0431\u0440\u044c",December:"\u0414\u0435\u043a\u0430\u0431\u0440\u044c",Jan_Abbr:"\u044f\u043d\u0432", +Feb_Abbr:"\u0444\u0435\u0432",Mar_Abbr:"\u043c\u0430\u0440",Apr_Abbr:"\u0430\u043f\u0440",May_Abbr:"\u043c\u0430\u0439",Jun_Abbr:"\u0438\u044e\u043d",Jul_Abbr:"\u0438\u044e\u043b",Aug_Abbr:"\u0430\u0432\u0433",Sep_Abbr:"\u0441\u0435\u043d",Oct_Abbr:"\u043e\u043a\u0442",Nov_Abbr:"\u043d\u043e\u044f",Dec_Abbr:"\u0434\u0435\u043a",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yyyy","dddd, MMMM dd, yyyy":"d MMMM yyyy '\u0433.'","h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"d MMMM yyyy '\u0433.' 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 '\u0433.'","/jan(uary)?/":"\u044f\u043d\u0432(\u0430\u0440\u044c)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0430\u043b\u044c)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0435\u043b\u044c)?","/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u0438\u044e\u043d(\u044c)?","/jul(y)?/":"\u0438\u044e\u043b(\u044c)?", +"/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043d(\u0442\u044f\u0431\u0440\u044c)?","/oct(ober)?/":"\u043e\u043a\u0442(\u044f\u0431\u0440\u044c)?","/nov(ember)?/":"\u043d\u043e\u044f(\u0431\u0440\u044c)?","/dec(ember)?/":"\u0434\u0435\u043a(\u0430\u0431\u0440\u044c)?","/^su(n(day)?)?/":"^\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435","/^mo(n(day)?)?/":"^\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a","/^tu(e(s(day)?)?)?/":"^\u0432\u0442\u043e\u0440\u043d\u0438\u043a", +"/^we(d(nesday)?)?/":"^\u0441\u0440\u0435\u0434\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435\u0442\u0432\u0435\u0440\u0433","/^fr(i(day)?)?/":"^\u043f\u044f\u0442\u043d\u0438\u0446\u0430","/^sa(t(urday)?)?/":"^\u0441\u0443\u0431\u0431\u043e\u0442\u0430","/^next/":"^\u0441\u043b\u0435\u0434|\u0437\u0430\u0432\u0442\u0440\u0430","/^last|past|prev(ious)?/":"^\u043f\u0440\u0435\u0434|\u0432\u0447\u0435\u0440\u0430","/^(\\+|aft(er)?|from|hence)/":"^(\\+|\u0447\u0435\u0440\u0435\u0437|\u043f\u043e\u0441\u043b\u0435|\u0432\u043f\u0435\u0440\u0435\u0434|\u0438|\u0441\u043b\u0435\u0434\u0443\u044e?\u0449(\u0430\u044f|\u0438\u0439|\u0435\u0435)?)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|\u0437\u0430|\u0434\u043e|\u043f\u043e\u0437\u0430|\u043f\u0435?\u0440\u0435\u0434((\u044b\u0434\u0443\u0449|\u0448\u0435\u0432?\u0441\u0442\u0432\u0443\u044e\u0449)(\u0430\u044f|\u0438\u0439|\u0435\u0435))|\u043d\u0430\u0437\u0430\u0434)","/^yes(terday)?/":"^\u0432\u0447\u0435\u0440\u0430","/^t(od(ay)?)?/":"^\u0441\u0435\u0433\u043e\u0434\u043d\u044f","/^tom(orrow)?/":"^\u0437\u0430\u0432\u0442\u0440\u0430","/^n(ow)?/":"^\u0441\u0435\u0439\u0447\u0430\u0441|\u0441\u0435\u0447\u0430\u0441|\u0449\u0430\u0441", +"/^ms|milli(second)?s?/":"^\u043c\u0441|\u043c\u0438\u043b\u0438(\u0441\u0435\u043a\u0443\u043d\u0434)?s?","/^sec(ond)?s?/":"^\u0441(\u0435\u043a(\u0443\u043d\u0434)?)?","/^mn|min(ute)?s?/":"^\u043c(\u0438\u043d(\u0443\u0442)?)?","/^h(our)?s?/":"^\u0447((\u0430\u0441)?\u043e\u0432)?","/^w(eek)?s?/":"^\u043d(\u0435\u0434(\u0435\u043b\u044c)?)?","/^m(onth)?s?/":"^\u043c\u0435\u0441(\u044f\u0446\u0435\u0432)?","/^d(ay)?s?/":"^\u0434(\u0435\u043d\u044c|\u043d\u0435\u0439|\u043d\u044f)?","/^y(ear)?s?/":"^\u0433(\u043e\u0434\u0430?)?|\u043b(\u0435\u0442)?", +"/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST", +NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sa-IN"]={name:"sa-IN",englishName:"Sanskrit (India)",nativeName:"\u0938\u0902\u0938\u094d\u0915\u0943\u0924 (\u092d\u093e\u0930\u0924\u092e\u094d)",Sunday:"\u0930\u0935\u093f\u0935\u093e\u0938\u0930\u0903",Monday:"\u0938\u094b\u092e\u0935\u093e\u0938\u0930\u0903",Tuesday:"\u092e\u0919\u094d\u0917\u0932\u0935\u093e\u0938\u0930\u0903",Wednesday:"\u092c\u0941\u0927\u0935\u093e\u0938\u0930\u0903",Thursday:"\u0917\u0941\u0930\u0941\u0935\u093e\u0938\u0930\u0903",Friday:"\u0936\u0941\u0915\u094d\u0930\u0935\u093e\u0938\u0930\u0903", +Saturday:"\u0936\u0928\u093f\u0935\u093e\u0938\u0930\u0903",Sun:"\u0930\u0935\u093f\u0935\u093e\u0938\u0930\u0903",Mon:"\u0938\u094b\u092e\u0935\u093e\u0938\u0930\u0903",Tue:"\u092e\u0919\u094d\u0917\u0932\u0935\u093e\u0938\u0930\u0903",Wed:"\u092c\u0941\u0927\u0935\u093e\u0938\u0930\u0903",Thu:"\u0917\u0941\u0930\u0941\u0935\u093e\u0938\u0930\u0903",Fri:"\u0936\u0941\u0915\u094d\u0930\u0935\u093e\u0938\u0930\u0903",Sat:"\u0936\u0928\u093f\u0935\u093e\u0938\u0930\u0903",Su:"\u0930",Mo:"\u0938",Tu:"\u092e", +We:"\u092c",Th:"\u0917",Fr:"\u0936",Sa:"\u0936",S_Sun_Initial:"\u0930",M_Mon_Initial:"\u0938",T_Tue_Initial:"\u092e",W_Wed_Initial:"\u092c",T_Thu_Initial:"\u0917",F_Fri_Initial:"\u0936",S_Sat_Initial:"\u0936",January:"\u091c\u0928\u0935\u0930\u0940",February:"\u092b\u0930\u0935\u0930\u0940",March:"\u092e\u093e\u0930\u094d\u091a",April:"\u0905\u092a\u094d\u0930\u0948\u0932",May:"\u092e\u0908",June:"\u091c\u0942\u0928",July:"\u091c\u0941\u0932\u093e\u0908",August:"\u0905\u0917\u0938\u094d\u0924",September:"\u0938\u093f\u0924\u092e\u094d\u092c\u0930", +October:"\u0905\u0915\u094d\u0924\u0942\u092c\u0930",November:"\u0928\u0935\u092e\u094d\u092c\u0930",December:"\u0926\u093f\u0938\u092e\u094d\u092c\u0930",Jan_Abbr:"\u091c\u0928\u0935\u0930\u0940",Feb_Abbr:"\u092b\u0930\u0935\u0930\u0940",Mar_Abbr:"\u092e\u093e\u0930\u094d\u091a",Apr_Abbr:"\u0905\u092a\u094d\u0930\u0948\u0932",May_Abbr:"\u092e\u0908",Jun_Abbr:"\u091c\u0942\u0928",Jul_Abbr:"\u091c\u0941\u0932\u093e\u0908",Aug_Abbr:"\u0905\u0917\u0938\u094d\u0924",Sep_Abbr:"\u0938\u093f\u0924\u092e\u094d\u092c\u0930", +Oct_Abbr:"\u0905\u0915\u094d\u0924\u0942\u092c\u0930",Nov_Abbr:"\u0928\u0935\u092e\u094d\u092c\u0930",Dec_Abbr:"\u0926\u093f\u0938\u092e\u094d\u092c\u0930",AM:"\u092a\u0942\u0930\u094d\u0935\u093e\u0939\u094d\u0928",PM:"\u0905\u092a\u0930\u093e\u0939\u094d\u0928",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)?/":"\u091c\u0928\u0935\u0930\u0940","/feb(ruary)?/":"\u092b\u0930\u0935\u0930\u0940","/mar(ch)?/":"\u092e\u093e\u0930\u094d\u091a","/apr(il)?/":"\u0905\u092a\u094d\u0930\u0948\u0932","/may/":"\u092e\u0908","/jun(e)?/":"\u091c\u0942\u0928","/jul(y)?/":"\u091c\u0941\u0932\u093e\u0908","/aug(ust)?/":"\u0905\u0917\u0938\u094d\u0924","/sep(t(ember)?)?/":"\u0938\u093f\u0924\u092e\u094d\u092c\u0930", +"/oct(ober)?/":"\u0905\u0915\u094d\u0924\u0942\u092c\u0930","/nov(ember)?/":"\u0928\u0935\u092e\u094d\u092c\u0930","/dec(ember)?/":"\u0926\u093f\u0938\u092e\u094d\u092c\u0930","/^su(n(day)?)?/":"^\u0930(1)?","/^mo(n(day)?)?/":"^\u0938(1)?","/^tu(e(s(day)?)?)?/":"^\u092e(1)?","/^we(d(nesday)?)?/":"^\u092c(1)?","/^th(u(r(s(day)?)?)?)?/":"^\u0917(1)?","/^fr(i(day)?)?/":"^\u0936(1)?","/^sa(t(urday)?)?/":"^\u0936(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["se-FI"]={name:"se-FI",englishName:"Sami (Northern) (Finland)",nativeName:"davvis\u00e1megiella (Suopma)",Sunday:"sotnabeaivi",Monday:"vuoss\u00e1rga",Tuesday:"ma\u014b\u014beb\u00e1rga",Wednesday:"gaskavahkku",Thursday:"duorastat",Friday:"bearjadat",Saturday:"l\u00e1vvardat",Sun:"sotn",Mon:"vuos",Tue:"ma\u014b",Wed:"gask",Thu:"duor",Fri:"bear",Sat:"l\u00e1v",Su:"sotn",Mo:"vuos",Tu:"ma\u014b",We:"gask",Th:"duor",Fr:"bear",Sa:"l\u00e1v",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\u0111\u0111ajagem\u00e1nnu",February:"guovvam\u00e1nnu",March:"njuk\u010dam\u00e1nnu",April:"cuo\u014bom\u00e1nnu",May:"miessem\u00e1nnu",June:"geassem\u00e1nnu",July:"suoidnem\u00e1nnu",August:"borgem\u00e1nnu",September:"\u010dak\u010dam\u00e1nnu",October:"golggotm\u00e1nnu",November:"sk\u00e1bmam\u00e1nnu",December:"juovlam\u00e1nnu",Jan_Abbr:"o\u0111\u0111j",Feb_Abbr:"guov",Mar_Abbr:"njuk",Apr_Abbr:"cuo",May_Abbr:"mies", +Jun_Abbr:"geas",Jul_Abbr:"suoi",Aug_Abbr:"borg",Sep_Abbr:"\u010dak\u010d",Oct_Abbr:"golg",Nov_Abbr:"sk\u00e1b",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\u0111\u0111ajagem\u00e1nnu","/feb(ruary)?/":"guov(vam\u00e1nnu)?","/mar(ch)?/":"njuk(\u010dam\u00e1nnu)?","/apr(il)?/":"cuo(\u014bom\u00e1nnu)?","/may/":"mies(sem\u00e1nnu)?","/jun(e)?/":"geas(sem\u00e1nnu)?","/jul(y)?/":"suoi(dnem\u00e1nnu)?","/aug(ust)?/":"borg(em\u00e1nnu)?","/sep(t(ember)?)?/":"\u010dak\u010d(am\u00e1nnu)?","/oct(ober)?/":"golg(gotm\u00e1nnu)?","/nov(ember)?/":"sk\u00e1b(mam\u00e1nnu)?","/dec(ember)?/":"juov(lam\u00e1nnu)?", +"/^su(n(day)?)?/":"^sotnabeaivi","/^mo(n(day)?)?/":"^vuoss\u00e1rga","/^tu(e(s(day)?)?)?/":"^ma\u014b\u014beb\u00e1rga","/^we(d(nesday)?)?/":"^gaskavahkku","/^th(u(r(s(day)?)?)?)?/":"^duorastat","/^fr(i(day)?)?/":"^bearjadat","/^sa(t(urday)?)?/":"^l\u00e1vvardat","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["se-NO"]={name:"se-NO",englishName:"Sami (Northern) (Norway)",nativeName:"davvis\u00e1megiella (Norga)",Sunday:"sotnabeaivi",Monday:"vuoss\u00e1rga",Tuesday:"ma\u014b\u014beb\u00e1rga",Wednesday:"gaskavahkku",Thursday:"duorastat",Friday:"bearjadat",Saturday:"l\u00e1vvardat",Sun:"sotn",Mon:"vuos",Tue:"ma\u014b",Wed:"gask",Thu:"duor",Fri:"bear",Sat:"l\u00e1v",Su:"sotn",Mo:"vuos",Tu:"ma\u014b",We:"gask",Th:"duor",Fr:"bear",Sa:"l\u00e1v",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\u0111\u0111ajagem\u00e1nnu",February:"guovvam\u00e1nnu",March:"njuk\u010dam\u00e1nnu",April:"cuo\u014bom\u00e1nnu",May:"miessem\u00e1nnu",June:"geassem\u00e1nnu",July:"suoidnem\u00e1nnu",August:"borgem\u00e1nnu",September:"\u010dak\u010dam\u00e1nnu",October:"golggotm\u00e1nnu",November:"sk\u00e1bmam\u00e1nnu",December:"juovlam\u00e1nnu",Jan_Abbr:"o\u0111\u0111j",Feb_Abbr:"guov",Mar_Abbr:"njuk",Apr_Abbr:"cuo",May_Abbr:"mies", +Jun_Abbr:"geas",Jul_Abbr:"suoi",Aug_Abbr:"borg",Sep_Abbr:"\u010dak\u010d",Oct_Abbr:"golg",Nov_Abbr:"sk\u00e1b",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\u0111\u0111ajagem\u00e1nnu","/feb(ruary)?/":"guov(vam\u00e1nnu)?","/mar(ch)?/":"njuk(\u010dam\u00e1nnu)?","/apr(il)?/":"cuo(\u014bom\u00e1nnu)?","/may/":"mies(sem\u00e1nnu)?","/jun(e)?/":"geas(sem\u00e1nnu)?","/jul(y)?/":"suoi(dnem\u00e1nnu)?","/aug(ust)?/":"borg(em\u00e1nnu)?","/sep(t(ember)?)?/":"\u010dak\u010d(am\u00e1nnu)?","/oct(ober)?/":"golg(gotm\u00e1nnu)?","/nov(ember)?/":"sk\u00e1b(mam\u00e1nnu)?","/dec(ember)?/":"juov(lam\u00e1nnu)?", +"/^su(n(day)?)?/":"^sotnabeaivi","/^mo(n(day)?)?/":"^vuoss\u00e1rga","/^tu(e(s(day)?)?)?/":"^ma\u014b\u014beb\u00e1rga","/^we(d(nesday)?)?/":"^gaskavahkku","/^th(u(r(s(day)?)?)?)?/":"^duorastat","/^fr(i(day)?)?/":"^bearjadat","/^sa(t(urday)?)?/":"^l\u00e1vvardat","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["se-SE"]={name:"se-SE",englishName:"Sami (Northern) (Sweden)",nativeName:"davvis\u00e1megiella (Ruo\u0167\u0167a)",Sunday:"sotnabeaivi",Monday:"m\u00e1nnodat",Tuesday:"disdat",Wednesday:"gaskavahkku",Thursday:"duorastat",Friday:"bearjadat",Saturday:"l\u00e1vvardat",Sun:"sotn",Mon:"m\u00e1n",Tue:"dis",Wed:"gask",Thu:"duor",Fri:"bear",Sat:"l\u00e1v",Su:"sotn",Mo:"m\u00e1n",Tu:"dis",We:"gask",Th:"duor",Fr:"bear",Sa:"l\u00e1v",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\u0111\u0111ajagem\u00e1nnu",February:"guovvam\u00e1nnu",March:"njuk\u010dam\u00e1nnu",April:"cuo\u014bom\u00e1nnu",May:"miessem\u00e1nnu",June:"geassem\u00e1nnu",July:"suoidnem\u00e1nnu",August:"borgem\u00e1nnu",September:"\u010dak\u010dam\u00e1nnu",October:"golggotm\u00e1nnu",November:"sk\u00e1bmam\u00e1nnu",December:"juovlam\u00e1nnu",Jan_Abbr:"o\u0111\u0111j",Feb_Abbr:"guov",Mar_Abbr:"njuk",Apr_Abbr:"cuo",May_Abbr:"mies", +Jun_Abbr:"geas",Jul_Abbr:"suoi",Aug_Abbr:"borg",Sep_Abbr:"\u010dak\u010d",Oct_Abbr:"golg",Nov_Abbr:"sk\u00e1b",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\u0111\u0111ajagem\u00e1nnu","/feb(ruary)?/":"guov(vam\u00e1nnu)?","/mar(ch)?/":"njuk(\u010dam\u00e1nnu)?","/apr(il)?/":"cuo(\u014bom\u00e1nnu)?","/may/":"mies(sem\u00e1nnu)?","/jun(e)?/":"geas(sem\u00e1nnu)?","/jul(y)?/":"suoi(dnem\u00e1nnu)?","/aug(ust)?/":"borg(em\u00e1nnu)?","/sep(t(ember)?)?/":"\u010dak\u010d(am\u00e1nnu)?","/oct(ober)?/":"golg(gotm\u00e1nnu)?","/nov(ember)?/":"sk\u00e1b(mam\u00e1nnu)?","/dec(ember)?/":"juov(lam\u00e1nnu)?", +"/^su(n(day)?)?/":"^sotnabeaivi","/^mo(n(day)?)?/":"^m\u00e1nnodat","/^tu(e(s(day)?)?)?/":"^disdat","/^we(d(nesday)?)?/":"^gaskavahkku","/^th(u(r(s(day)?)?)?)?/":"^duorastat","/^fr(i(day)?)?/":"^bearjadat","/^sa(t(urday)?)?/":"^l\u00e1vvardat","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?", +"/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sk-SK"]={name:"sk-SK",englishName:"Slovak (Slovakia)",nativeName:"sloven\u010dina (Slovensk\u00e1 republika)",Sunday:"nede\u013ea",Monday:"pondelok",Tuesday:"utorok",Wednesday:"streda",Thursday:"\u0161tvrtok",Friday:"piatok",Saturday:"sobota",Sun:"ne",Mon:"po",Tue:"ut",Wed:"st",Thu:"\u0161t",Fri:"pi",Sat:"so",Su:"ne",Mo:"po",Tu:"ut",We:"st",Th:"\u0161t",Fr:"pi",Sa:"so",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u0161",F_Fri_Initial:"p", +S_Sat_Initial:"s",January:"janu\u00e1r",February:"febru\u00e1r",March:"marec",April:"apr\u00edl",May:"m\u00e1j",June:"j\u00fan",July:"j\u00fal",August:"august",September:"september",October:"okt\u00f3ber",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\u00e1r","/feb(ruary)?/":"febru\u00e1r","/mar(ch)?/":"marec","/apr(il)?/":"apr\u00edl","/may/":"m\u00e1j","/jun(e)?/":"j\u00fan","/jul(y)?/":"j\u00fal","/aug(ust)?/":"august","/sep(t(ember)?)?/":"sep(t(ember)?)?", +"/oct(ober)?/":"okt\u00f3ber","/nov(ember)?/":"november","/dec(ember)?/":"december","/^su(n(day)?)?/":"^nede\u013ea","/^mo(n(day)?)?/":"^pondelok","/^tu(e(s(day)?)?)?/":"^utorok","/^we(d(nesday)?)?/":"^streda","/^th(u(r(s(day)?)?)?)?/":"^\u0161tvrtok","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detrtek",Friday:"petek",Saturday:"sobota",Sun:"ned",Mon:"pon",Tue:"tor",Wed:"sre",Thu:"\u010det",Fri:"pet",Sat:"sob",Su:"ne",Mo:"po",Tu:"to",We:"sr",Th:"\u010de",Fr:"pe",Sa:"so",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"t",W_Wed_Initial:"s",T_Thu_Initial:"\u010d",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)?)?)?)?/":"^\u010de(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sma-NO"]={name:"sma-NO",englishName:"Sami (Southern) (Norway)",nativeName:"\u00e5arjelsaemiengiele (N\u00f6\u00f6rje)",Sunday:"aejlege",Monday:"m\u00e5anta",Tuesday:"d\u00e6jsta",Wednesday:"gaskev\u00e5hkoe",Thursday:"duarsta",Friday:"bearjadahke",Saturday:"laavvardahke",Sun:"aej",Mon:"m\u00e5a",Tue:"d\u00e6j",Wed:"gask",Thu:"duar",Fri:"bearj",Sat:"laav",Su:"aej",Mo:"m\u00e5a",Tu:"d\u00e6j",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\u00efengele",February:"goevte",March:"njoktje",April:"voerhtje",May:"suehpede",June:"ruffie",July:"snjaltje",August:"m\u00efetske",September:"sk\u00eferede",October:"golke",November:"rahka",December:"goeve",Jan_Abbr:"ts\u00efen",Feb_Abbr:"goevt",Mar_Abbr:"njok",Apr_Abbr:"voer",May_Abbr:"sueh",Jun_Abbr:"ruff",Jul_Abbr:"snja",Aug_Abbr:"m\u00efet",Sep_Abbr:"sk\u00efer",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\u00efen(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\u00efet(ske)?","/sep(t(ember)?)?/":"sk\u00efer(ede)?","/oct(ober)?/":"golk(e)?","/nov(ember)?/":"rahk(a)?","/dec(ember)?/":"goev(e)?","/^su(n(day)?)?/":"^aejlege","/^mo(n(day)?)?/":"^m\u00e5anta","/^tu(e(s(day)?)?)?/":"^d\u00e6jsta","/^we(d(nesday)?)?/":"^gaskev\u00e5hkoe","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sma-SE"]={name:"sma-SE",englishName:"Sami (Southern) (Sweden)",nativeName:"\u00e5arjelsaemiengiele (Sveerje)",Sunday:"aejlege",Monday:"m\u00e5anta",Tuesday:"d\u00e6jsta",Wednesday:"gaskev\u00e5hkoe",Thursday:"duarsta",Friday:"bearjadahke",Saturday:"laavvardahke",Sun:"aej",Mon:"m\u00e5a",Tue:"d\u00e6j",Wed:"gask",Thu:"duar",Fri:"bearj",Sat:"laav",Su:"aej",Mo:"m\u00e5a",Tu:"d\u00e6j",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\u00efengele",February:"goevte",March:"njoktje",April:"voerhtje",May:"suehpede",June:"ruffie",July:"snjaltje",August:"m\u00efetske",September:"sk\u00eferede",October:"golke",November:"rahka",December:"goeve",Jan_Abbr:"ts\u00efen",Feb_Abbr:"goevt",Mar_Abbr:"njok",Apr_Abbr:"voer",May_Abbr:"sueh",Jun_Abbr:"ruff",Jul_Abbr:"snja",Aug_Abbr:"m\u00efet",Sep_Abbr:"sk\u00efer",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\u00efen(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\u00efet(ske)?","/sep(t(ember)?)?/":"sk\u00efer(ede)?","/oct(ober)?/":"golk(e)?","/nov(ember)?/":"rahk(a)?","/dec(ember)?/":"goev(e)?","/^su(n(day)?)?/":"^aejlege","/^mo(n(day)?)?/":"^m\u00e5anta","/^tu(e(s(day)?)?)?/":"^d\u00e6jsta","/^we(d(nesday)?)?/":"^gaskev\u00e5hkoe","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["smj-NO"]={name:"smj-NO",englishName:"Sami (Lule) (Norway)",nativeName:"julevus\u00e1megiella (Vuodna)",Sunday:"s\u00e5dn\u00e5biejvve",Monday:"m\u00e1nnodahka",Tuesday:"dijstahka",Wednesday:"gasskavahkko",Thursday:"duorastahka",Friday:"bierjjedahka",Saturday:"l\u00e1vvodahka",Sun:"s\u00e5d",Mon:"m\u00e1n",Tue:"dis",Wed:"gas",Thu:"duor",Fri:"bier",Sat:"l\u00e1v",Su:"s\u00e5d",Mo:"m\u00e1n",Tu:"dis",We:"gas",Th:"duor",Fr:"bier",Sa:"l\u00e1v",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:"\u00e5d\u00e5jakm\u00e1nno",February:"guovvam\u00e1nno",March:"sjnjuktjam\u00e1nno",April:"vuoratjism\u00e1nno",May:"moarmesm\u00e1nno",June:"biehtsem\u00e1nno",July:"sjnjilltjam\u00e1nno",August:"b\u00e5rggem\u00e1nno",September:"rag\u00e1tm\u00e1nno",October:"g\u00e5lg\u00e5dism\u00e1nno",November:"bas\u00e1dism\u00e1nno",December:"javllam\u00e1nno",Jan_Abbr:"\u00e5d\u00e5j",Feb_Abbr:"guov",Mar_Abbr:"snju", +Apr_Abbr:"vuor",May_Abbr:"moar",Jun_Abbr:"bieh",Jul_Abbr:"snji",Aug_Abbr:"b\u00e5rg",Sep_Abbr:"rag\u00e1",Oct_Abbr:"g\u00e5lg",Nov_Abbr:"bas\u00e1",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)?/":"\u00e5d\u00e5j(akm\u00e1nno)?","/feb(ruary)?/":"guov(vam\u00e1nno)?","/mar(ch)?/":"sjnjuktjam\u00e1nno","/apr(il)?/":"vuor(atjism\u00e1nno)?","/may/":"moar(mesm\u00e1nno)?","/jun(e)?/":"bieh(tsem\u00e1nno)?","/jul(y)?/":"sjnjilltjam\u00e1nno","/aug(ust)?/":"b\u00e5rg(gem\u00e1nno)?","/sep(t(ember)?)?/":"rag\u00e1(tm\u00e1nno)?","/oct(ober)?/":"g\u00e5lg(\u00e5dism\u00e1nno)?","/nov(ember)?/":"bas\u00e1(dism\u00e1nno)?","/dec(ember)?/":"javl(lam\u00e1nno)?", +"/^su(n(day)?)?/":"^s\u00e5dn\u00e5biejvve","/^mo(n(day)?)?/":"^m\u00e1nnodahka","/^tu(e(s(day)?)?)?/":"^dijstahka","/^we(d(nesday)?)?/":"^gasskavahkko","/^th(u(r(s(day)?)?)?)?/":"^duorastahka","/^fr(i(day)?)?/":"^bierjjedahka","/^sa(t(urday)?)?/":"^l\u00e1vvodahka","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?", +"/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["smj-SE"]={name:"smj-SE",englishName:"Sami (Lule) (Sweden)",nativeName:"julevus\u00e1megiella (Svierik)",Sunday:"\u00e1jllek",Monday:"m\u00e1nnodahka",Tuesday:"dijstahka",Wednesday:"gasskavahkko",Thursday:"duorastahka",Friday:"bierjjedahka",Saturday:"l\u00e1vvodahka",Sun:"\u00e1jl",Mon:"m\u00e1n",Tue:"dis",Wed:"gas",Thu:"duor",Fri:"bier",Sat:"l\u00e1v",Su:"\u00e1jl",Mo:"m\u00e1n",Tu:"dis",We:"gas",Th:"duor",Fr:"bier",Sa:"l\u00e1v",S_Sun_Initial:"\u00e1",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:"\u00e5d\u00e5jakm\u00e1nno",February:"guovvam\u00e1nno",March:"sjnjuktjam\u00e1nno",April:"vuoratjism\u00e1nno",May:"moarmesm\u00e1nno",June:"biehtsem\u00e1nno",July:"sjnjilltjam\u00e1nno",August:"b\u00e5rggem\u00e1nno",September:"rag\u00e1tm\u00e1nno",October:"g\u00e5lg\u00e5dism\u00e1nno",November:"bas\u00e1dism\u00e1nno",December:"javllam\u00e1nno",Jan_Abbr:"\u00e5d\u00e5j",Feb_Abbr:"guov",Mar_Abbr:"snju",Apr_Abbr:"vuor", +May_Abbr:"moar",Jun_Abbr:"bieh",Jul_Abbr:"snji",Aug_Abbr:"b\u00e5rg",Sep_Abbr:"rag\u00e1",Oct_Abbr:"g\u00e5lg",Nov_Abbr:"bas\u00e1",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)?/":"\u00e5d\u00e5j(akm\u00e1nno)?","/feb(ruary)?/":"guov(vam\u00e1nno)?","/mar(ch)?/":"sjnjuktjam\u00e1nno","/apr(il)?/":"vuor(atjism\u00e1nno)?","/may/":"moar(mesm\u00e1nno)?","/jun(e)?/":"bieh(tsem\u00e1nno)?","/jul(y)?/":"sjnjilltjam\u00e1nno","/aug(ust)?/":"b\u00e5rg(gem\u00e1nno)?","/sep(t(ember)?)?/":"rag\u00e1(tm\u00e1nno)?","/oct(ober)?/":"g\u00e5lg(\u00e5dism\u00e1nno)?","/nov(ember)?/":"bas\u00e1(dism\u00e1nno)?","/dec(ember)?/":"javl(lam\u00e1nno)?", +"/^su(n(day)?)?/":"^\u00e1jllek","/^mo(n(day)?)?/":"^m\u00e1nnodahka","/^tu(e(s(day)?)?)?/":"^dijstahka","/^we(d(nesday)?)?/":"^gasskavahkko","/^th(u(r(s(day)?)?)?)?/":"^duorastahka","/^fr(i(day)?)?/":"^bierjjedahka","/^sa(t(urday)?)?/":"^l\u00e1vvodahka","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?", +"/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["smn-FI"]={name:"smn-FI",englishName:"Sami (Inari) (Finland)",nativeName:"s\u00e4mikiel\u00e2 (Suom\u00e2)",Sunday:"pasepeivi",Monday:"vuossarg\u00e2",Tuesday:"majebarg\u00e2",Wednesday:"koskokko",Thursday:"tuor\u00e2st\u00e2h",Friday:"v\u00e1stuppeivi",Saturday:"l\u00e1v\u00e1rd\u00e2h",Sun:"pa",Mon:"vu",Tue:"ma",Wed:"ko",Thu:"tu",Fri:"v\u00e1",Sat:"l\u00e1",Su:"pa",Mo:"vu",Tu:"ma",We:"ko",Th:"tu",Fr:"v\u00e1",Sa:"l\u00e1",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\u0111\u0111\u00e2ivem\u00e1\u00e1nu",February:"kuov\u00e2m\u00e1\u00e1nu",March:"njuh\u010d\u00e2m\u00e1\u00e1nu",April:"cu\u00e1\u014buim\u00e1\u00e1nu",May:"vyesim\u00e1\u00e1nu",June:"kesim\u00e1\u00e1nu",July:"syeinim\u00e1\u00e1nu",August:"porgem\u00e1\u00e1nu",September:"\u010doh\u010d\u00e2m\u00e1\u00e1nu",October:"roovv\u00e2dm\u00e1\u00e1nu",November:"skamm\u00e2m\u00e1\u00e1nu",December:"juovl\u00e2m\u00e1\u00e1nu", +Jan_Abbr:"u\u0111iv",Feb_Abbr:"kuov",Mar_Abbr:"njuh",Apr_Abbr:"cuo\u014b",May_Abbr:"vyes",Jun_Abbr:"kesi",Jul_Abbr:"syei",Aug_Abbr:"porg",Sep_Abbr:"\u010doh",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\u0111\u0111\u00e2ivem\u00e1\u00e1nu","/feb(ruary)?/":"kuov(\u00e2m\u00e1\u00e1nu)?","/mar(ch)?/":"njuh(\u010d\u00e2m\u00e1\u00e1nu)?","/apr(il)?/":"cu\u00e1\u014buim\u00e1\u00e1nu","/may/":"vyes(im\u00e1\u00e1nu)?","/jun(e)?/":"kesi(m\u00e1\u00e1nu)?","/jul(y)?/":"syei(nim\u00e1\u00e1nu)?","/aug(ust)?/":"porg(em\u00e1\u00e1nu)?","/sep(t(ember)?)?/":"\u010doh(\u010d\u00e2m\u00e1\u00e1nu)?", +"/oct(ober)?/":"roov(v\u00e2dm\u00e1\u00e1nu)?","/nov(ember)?/":"ska(mm\u00e2m\u00e1\u00e1nu)?","/dec(ember)?/":"juov(l\u00e2m\u00e1\u00e1nu)?","/^su(n(day)?)?/":"^pasepeivi","/^mo(n(day)?)?/":"^vuossarg\u00e2","/^tu(e(s(day)?)?)?/":"^majebarg\u00e2","/^we(d(nesday)?)?/":"^koskokko","/^th(u(r(s(day)?)?)?)?/":"^tuor\u00e2st\u00e2h","/^fr(i(day)?)?/":"^v\u00e1stuppeivi","/^sa(t(urday)?)?/":"^l\u00e1v\u00e1rd\u00e2h","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sms-FI"]={name:"sms-FI",englishName:"Sami (Skolt) (Finland)",nativeName:"s\u00e4\u00e4m\u00b4\u01e9i\u00f5ll (L\u00e4\u00e4\u00b4ddj\u00e2nnam)",Sunday:"p\u00e2\u00b4sspei\u00b4vv",Monday:"vu\u00f5ssargg",Tuesday:"m\u00e2\u00e2ibargg",Wednesday:"se\u00e4rad",Thursday:"nelljdpei\u00b4vv",Friday:"pi\u00e2tn\u00e2c",Saturday:"sue\u00b4vet",Sun:"p\u00e2",Mon:"vu",Tue:"m\u00e2",Wed:"se",Thu:"ne",Fri:"pi",Sat:"su",Su:"p\u00e2",Mo:"vu",Tu:"m\u00e2",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\u0111\u0111ee\u00b4jjm\u00e4\u00e4n",February:"t\u00e4\u00b4lvvm\u00e4\u00e4n",March:"p\u00e2\u00b4zzl\u00e2\u0161ttamm\u00e4\u00e4n",April:"njuh\u010d\u010dm\u00e4\u00e4n",May:"vue\u00b4ssm\u00e4\u00e4n",June:"\u01e9ie\u00b4ssm\u00e4\u00e4n",July:"suei\u00b4nnm\u00e4\u00e4n",August:"p\u00e5\u00b4r\u01e7\u01e7m\u00e4\u00e4n",September:"\u010d\u00f5h\u010d\u010dm\u00e4\u00e4n",October:"k\u00e5lggm\u00e4\u00e4n", +November:"skamm\u00b4m\u00e4\u00e4n",December:"rosttovm\u00e4\u00e4n",Jan_Abbr:"o\u0111jm",Feb_Abbr:"t\u00e4\u00b4lvv",Mar_Abbr:"p\u00e2zl",Apr_Abbr:"njuh",May_Abbr:"vue",Jun_Abbr:"\u01e9ie",Jul_Abbr:"suei",Aug_Abbr:"p\u00e5\u00b4r",Sep_Abbr:"\u010d\u00f5h",Oct_Abbr:"k\u00e5lg",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\u0111\u0111ee\u00b4jjm\u00e4\u00e4n","/feb(ruary)?/":"t\u00e4\u00b4lvv(m\u00e4\u00e4n)?","/mar(ch)?/":"p\u00e2\u00b4zzl\u00e2\u0161ttamm\u00e4\u00e4n","/apr(il)?/":"njuh(\u010d\u010dm\u00e4\u00e4n)?","/may/":"vue(\u00b4ssm\u00e4\u00e4n)?","/jun(e)?/":"\u01e9ie(\u00b4ssm\u00e4\u00e4n)?","/jul(y)?/":"suei(\u00b4nnm\u00e4\u00e4n)?", +"/aug(ust)?/":"p\u00e5\u00b4r(\u01e7\u01e7m\u00e4\u00e4n)?","/sep(t(ember)?)?/":"\u010d\u00f5h(\u010d\u010dm\u00e4\u00e4n)?","/oct(ober)?/":"k\u00e5lg(gm\u00e4\u00e4n)?","/nov(ember)?/":"ska(mm\u00b4m\u00e4\u00e4n)?","/dec(ember)?/":"rost(tovm\u00e4\u00e4n)?","/^su(n(day)?)?/":"^p\u00e2\u00b4sspei\u00b4vv","/^mo(n(day)?)?/":"^vu\u00f5ssargg","/^tu(e(s(day)?)?)?/":"^m\u00e2\u00e2ibargg","/^we(d(nesday)?)?/":"^se\u00e4rad","/^th(u(r(s(day)?)?)?)?/":"^nelljdpei\u00b4vv","/^fr(i(day)?)?/":"^pi\u00e2tn\u00e2c", +"/^sa(t(urday)?)?/":"^sue\u00b4vet","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?", +"/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST", +ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sq-AL"]={name:"sq-AL",englishName:"Albanian (Albania)",nativeName:"shqipe (Shqip\u00ebria)",Sunday:"e diel",Monday:"e h\u00ebn\u00eb",Tuesday:"e mart\u00eb",Wednesday:"e m\u00ebrkur\u00eb",Thursday:"e enjte",Friday:"e premte",Saturday:"e shtun\u00eb",Sun:"Die",Mon:"H\u00ebn",Tue:"Mar",Wed:"M\u00ebr",Thu:"Enj",Fri:"Pre",Sat:"Sht",Su:"Di",Mo:"H\u00eb",Tu:"Ma",We:"M\u00eb",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\u00ebntor",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\u00ebn",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\u00ebn(tor)?","/dec(ember)?/":"dhj(etor)?","/^su(n(day)?)?/":"^di(e(iel)?)?","/^mo(n(day)?)?/":"^h\u00eb(n(\u00ebn\u00eb)?)?","/^tu(e(s(day)?)?)?/":"^ma(r(art\u00eb)?)?","/^we(d(nesday)?)?/":"^m\u00eb(r(\u00ebrkur\u00eb)?)?","/^th(u(r(s(day)?)?)?)?/":"^en(j(njte)?)?","/^fr(i(day)?)?/":"^pr(e(remte)?)?","/^sa(t(urday)?)?/":"^sh(t(htun\u00eb)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sr-Cyrl-BA"]={name:"sr-Cyrl-BA",englishName:"Serbian (Cyrillic) (Bosnia and Herzegovina)",nativeName:"\u0441\u0440\u043f\u0441\u043a\u0438 (\u0411\u043e\u0441\u043d\u0430 \u0438 \u0425\u0435\u0440\u0446\u0435\u0433\u043e\u0432\u0438\u043d\u0430)",Sunday:"\u043d\u0435\u0434\u0435\u0459\u0430",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u0459\u0430\u043a",Tuesday:"\u0443\u0442\u043e\u0440\u0430\u043a",Wednesday:"\u0441\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0440\u0442\u0430\u043a", +Friday:"\u043f\u0435\u0442\u0430\u043a",Saturday:"\u0441\u0443\u0431\u043e\u0442\u0430",Sun:"\u043d\u0435\u0434",Mon:"\u043f\u043e\u043d",Tue:"\u0443\u0442\u043e",Wed:"\u0441\u0440\u0435",Thu:"\u0447\u0435\u0442",Fri:"\u043f\u0435\u0442",Sat:"\u0441\u0443\u0431",Su:"\u043d\u0435\u0434",Mo:"\u043f\u043e\u043d",Tu:"\u0443\u0442\u043e",We:"\u0441\u0440\u0435",Th:"\u0447\u0435\u0442",Fr:"\u043f\u0435\u0442",Sa:"\u0441\u0443\u0431",S_Sun_Initial:"\u043d",M_Mon_Initial:"\u043f",T_Tue_Initial:"\u0443",W_Wed_Initial:"\u0441", +T_Thu_Initial:"\u0447",F_Fri_Initial:"\u043f",S_Sat_Initial:"\u0441",January:"\u0458\u0430\u043d\u0443\u0430\u0440",February:"\u0444\u0435\u0431\u0440\u0443\u0430\u0440",March:"\u043c\u0430\u0440\u0442",April:"\u0430\u043f\u0440\u0438\u043b",May:"\u043c\u0430\u0458",June:"\u0458\u0443\u043d",July:"\u0458\u0443\u043b",August:"\u0430\u0432\u0433\u0443\u0441\u0442",September:"\u0441\u0435\u043f\u0442\u0435\u043c\u0431\u0430\u0440",October:"\u043e\u043a\u0442\u043e\u0431\u0430\u0440",November:"\u043d\u043e\u0432\u0435\u043c\u0431\u0430\u0440", +December:"\u0434\u0435\u0446\u0435\u043c\u0431\u0430\u0440",Jan_Abbr:"\u0458\u0430\u043d",Feb_Abbr:"\u0444\u0435\u0431",Mar_Abbr:"\u043c\u0430\u0440",Apr_Abbr:"\u0430\u043f\u0440",May_Abbr:"\u043c\u0430\u0458",Jun_Abbr:"\u0458\u0443\u043d",Jul_Abbr:"\u0458\u0443\u043b",Aug_Abbr:"\u0430\u0432\u0433",Sep_Abbr:"\u0441\u0435\u043f",Oct_Abbr:"\u043e\u043a\u0442",Nov_Abbr:"\u043d\u043e\u0432",Dec_Abbr:"\u0434\u0435\u0446",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)?/":"\u0458\u0430\u043d(\u0443\u0430\u0440)?","/feb(ruary)?/":"\u0444\u0435\u0431(\u0440\u0443\u0430\u0440)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0438\u043b)?", +"/may/":"\u043c\u0430\u0458","/jun(e)?/":"\u0458\u0443\u043d","/jul(y)?/":"\u0458\u0443\u043b","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043f(\u0442\u0435\u043c\u0431\u0430\u0440)?","/oct(ober)?/":"\u043e\u043a\u0442(\u043e\u0431\u0430\u0440)?","/nov(ember)?/":"\u043d\u043e\u0432(\u0435\u043c\u0431\u0430\u0440)?","/dec(ember)?/":"\u0434\u0435\u0446(\u0435\u043c\u0431\u0430\u0440)?","/^su(n(day)?)?/":"^\u043d\u0435\u0434\u0435\u0459\u0430","/^mo(n(day)?)?/":"^\u043f\u043e\u043d\u0435\u0434\u0435\u0459\u0430\u043a", +"/^tu(e(s(day)?)?)?/":"^\u0443\u0442\u043e\u0440\u0430\u043a","/^we(d(nesday)?)?/":"^\u0441\u0440\u0435\u0434\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435\u0442\u0432\u0440\u0442\u0430\u043a","/^fr(i(day)?)?/":"^\u043f\u0435\u0442\u0430\u043a","/^sa(t(urday)?)?/":"^\u0441\u0443\u0431\u043e\u0442\u0430","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?", +"/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sr-Cyrl-CS"]={name:"sr-Cyrl-CS",englishName:"Serbian (Cyrillic, Serbia)",nativeName:"\u0441\u0440\u043f\u0441\u043a\u0438 (\u0421\u0440\u0431\u0438\u0458\u0430)",Sunday:"\u043d\u0435\u0434\u0435\u0459\u0430",Monday:"\u043f\u043e\u043d\u0435\u0434\u0435\u0459\u0430\u043a",Tuesday:"\u0443\u0442\u043e\u0440\u0430\u043a",Wednesday:"\u0441\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0440\u0442\u0430\u043a",Friday:"\u043f\u0435\u0442\u0430\u043a",Saturday:"\u0441\u0443\u0431\u043e\u0442\u0430", +Sun:"\u043d\u0435\u0434",Mon:"\u043f\u043e\u043d",Tue:"\u0443\u0442\u043e",Wed:"\u0441\u0440\u0435",Thu:"\u0447\u0435\u0442",Fri:"\u043f\u0435\u0442",Sat:"\u0441\u0443\u0431",Su:"\u043d\u0435",Mo:"\u043f\u043e",Tu:"\u0443\u0442",We:"\u0441\u0440",Th:"\u0447\u0435",Fr:"\u043f\u0435",Sa:"\u0441\u0443",S_Sun_Initial:"\u043d",M_Mon_Initial:"\u043f",T_Tue_Initial:"\u0443",W_Wed_Initial:"\u0441",T_Thu_Initial:"\u0447",F_Fri_Initial:"\u043f",S_Sat_Initial:"\u0441",January:"\u0458\u0430\u043d\u0443\u0430\u0440", +February:"\u0444\u0435\u0431\u0440\u0443\u0430\u0440",March:"\u043c\u0430\u0440\u0442",April:"\u0430\u043f\u0440\u0438\u043b",May:"\u043c\u0430\u0458",June:"\u0458\u0443\u043d",July:"\u0458\u0443\u043b",August:"\u0430\u0432\u0433\u0443\u0441\u0442",September:"\u0441\u0435\u043f\u0442\u0435\u043c\u0431\u0430\u0440",October:"\u043e\u043a\u0442\u043e\u0431\u0430\u0440",November:"\u043d\u043e\u0432\u0435\u043c\u0431\u0430\u0440",December:"\u0434\u0435\u0446\u0435\u043c\u0431\u0430\u0440",Jan_Abbr:"\u0458\u0430\u043d", +Feb_Abbr:"\u0444\u0435\u0431",Mar_Abbr:"\u043c\u0430\u0440",Apr_Abbr:"\u0430\u043f\u0440",May_Abbr:"\u043c\u0430\u0458",Jun_Abbr:"\u0458\u0443\u043d",Jul_Abbr:"\u0458\u0443\u043b",Aug_Abbr:"\u0430\u0432\u0433",Sep_Abbr:"\u0441\u0435\u043f",Oct_Abbr:"\u043e\u043a\u0442",Nov_Abbr:"\u043d\u043e\u0432",Dec_Abbr:"\u0434\u0435\u0446",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)?/":"\u0458\u0430\u043d(\u0443\u0430\u0440)?","/feb(ruary)?/":"\u0444\u0435\u0431(\u0440\u0443\u0430\u0440)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0438\u043b)?","/may/":"\u043c\u0430\u0458","/jun(e)?/":"\u0458\u0443\u043d","/jul(y)?/":"\u0458\u0443\u043b","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?", +"/sep(t(ember)?)?/":"\u0441\u0435\u043f(\u0442\u0435\u043c\u0431\u0430\u0440)?","/oct(ober)?/":"\u043e\u043a\u0442(\u043e\u0431\u0430\u0440)?","/nov(ember)?/":"\u043d\u043e\u0432(\u0435\u043c\u0431\u0430\u0440)?","/dec(ember)?/":"\u0434\u0435\u0446(\u0435\u043c\u0431\u0430\u0440)?","/^su(n(day)?)?/":"^\u043d\u0435(\u0434(\u0435\u0459\u0430)?)?","/^mo(n(day)?)?/":"^\u043f\u043e(\u043d(\u0435\u0434\u0435\u0459\u0430\u043a)?)?","/^tu(e(s(day)?)?)?/":"^\u0443\u0442(\u043e(\u0440\u0430\u043a)?)?","/^we(d(nesday)?)?/":"^\u0441\u0440(\u0435(\u0434\u0430)?)?", +"/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435(\u0442(\u0432\u0440\u0442\u0430\u043a)?)?","/^fr(i(day)?)?/":"^\u043f\u0435(\u0442(\u0430\u043a)?)?","/^sa(t(urday)?)?/":"^\u0441\u0443(\u0431(\u043e\u0442\u0430)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?", +"/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detvrtak",Friday:"petak",Saturday:"subota",Sun:"ned",Mon:"pon",Tue:"uto",Wed:"sre",Thu:"\u010det",Fri:"pet",Sat:"sub",Su:"ned",Mo:"pon",Tu:"uto",We:"sre",Th:"\u010det",Fr:"pet",Sa:"sub",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u010d", +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)?)?)?)?/":"^\u010detvrtak","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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:"\u010detvrtak",Friday:"petak",Saturday:"subota",Sun:"ned",Mon:"pon",Tue:"uto",Wed:"sre",Thu:"\u010det",Fri:"pet",Sat:"sub",Su:"ne",Mo:"po",Tu:"ut",We:"sr",Th:"\u010de",Fr:"pe",Sa:"su",S_Sun_Initial:"n",M_Mon_Initial:"p",T_Tue_Initial:"u",W_Wed_Initial:"s",T_Thu_Initial:"\u010d",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)?)?)?)?/":"^\u010de(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sv-FI"]={name:"sv-FI",englishName:"Swedish (Finland)",nativeName:"svenska (Finland)",Sunday:"s\u00f6ndag",Monday:"m\u00e5ndag",Tuesday:"tisdag",Wednesday:"onsdag",Thursday:"torsdag",Friday:"fredag",Saturday:"l\u00f6rdag",Sun:"s\u00f6",Mon:"m\u00e5",Tue:"ti",Wed:"on",Thu:"to",Fri:"fr",Sat:"l\u00f6",Su:"s\u00f6",Mo:"m\u00e5",Tu:"ti",We:"on",Th:"to",Fr:"fr",Sa:"l\u00f6",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\u00f6ndag","/^mo(n(day)?)?/":"^m\u00e5ndag","/^tu(e(s(day)?)?)?/":"^tisdag","/^we(d(nesday)?)?/":"^onsdag","/^th(u(r(s(day)?)?)?)?/":"^torsdag","/^fr(i(day)?)?/":"^fredag","/^sa(t(urday)?)?/":"^l\u00f6rdag","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?", +"/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["sv-SE"]={name:"sv-SE",englishName:"Swedish (Sweden)",nativeName:"Svenska (Sverige)",Sunday:"S\u00f6ndag",Monday:"M\u00e5ndag",Tuesday:"Tisdag",Wednesday:"Onsdag",Thursday:"Torsdag",Friday:"Fredag",Saturday:"L\u00f6rdag",Sun:"S\u00f6n",Mon:"M\u00e5n",Tue:"Tis",Wed:"Ons",Thu:"Tor",Fri:"Fre",Sat:"L\u00f6r",Su:"S\u00f6",Mo:"M\u00e5",Tu:"Ti",We:"On",Th:"To",Fr:"Fr",Sa:"L\u00f6",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\u00f6(n(dag)?)?","/^mo(n(day)?)?/":"^m\u00e5(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\u00f6(r(dag)?)?","/^next/":"^n\u00e4sta","/^last|past|prev(ious)?/":"^f\u00f6reg\u00e5ende|f\u00f6rra|senaste","/^(\\+|aft(er)?|from|hence)/":"^(\\+|efter|fr\u00e5n)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|f\u00f6re|tidigare)","/^yes(terday)?/":"^i\\s?g\u00e5r|(f\u00f6r)g\u00e5r(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(\u00e5nad)?(er)?","/^d(ay)?s?/":"^d(ag)?(ar)?","/^y(ear)?s?/":"^\u00e5(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["syr-SY"]={name:"syr-SY",englishName:"Syriac (Syria)",nativeName:"\u0723\u0718\u072a\u071d\u071d\u0710 (\u0633\u0648\u0631\u064a\u0627)",Sunday:"\u071a\u0715\u00a0\u0712\u072b\u0712\u0710",Monday:"\u072c\u072a\u071d\u0722\u00a0\u0712\u072b\u0712\u0710",Tuesday:"\u072c\u0720\u072c\u0710\u00a0\u0712\u072b\u0712\u0710",Wednesday:"\u0710\u072a\u0712\u0725\u0710\u00a0\u0712\u072b\u0712\u0710",Thursday:"\u071a\u0721\u072b\u0710\u00a0\u0712\u072b\u0712\u0710",Friday:"\u0725\u072a\u0718\u0712\u072c\u0710", +Saturday:"\u072b\u0712\u072c\u0710",Sun:"\u070f\u0710\u00a0\u070f\u0712\u072b",Mon:"\u070f\u0712\u00a0\u070f\u0712\u072b",Tue:"\u070f\u0713\u00a0\u070f\u0712\u072b",Wed:"\u070f\u0715\u00a0\u070f\u0712\u072b",Thu:"\u070f\u0717\u00a0\u070f\u0712\u072b",Fri:"\u070f\u0725\u072a\u0718\u0712",Sat:"\u070f\u072b\u0712",Su:"\u070f",Mo:"\u070f",Tu:"\u070f",We:"\u070f",Th:"\u070f",Fr:"\u070f",Sa:"\u070f",S_Sun_Initial:"\u070f",M_Mon_Initial:"\u070f",T_Tue_Initial:"\u070f",W_Wed_Initial:"\u070f",T_Thu_Initial:"\u070f", +F_Fri_Initial:"\u070f",S_Sat_Initial:"\u070f",January:"\u071f\u0722\u0718\u0722\u00a0\u0710\u071a\u072a\u071d",February:"\u072b\u0712\u071b",March:"\u0710\u0715\u072a",April:"\u0722\u071d\u0723\u0722",May:"\u0710\u071d\u072a",June:"\u071a\u0719\u071d\u072a\u0722",July:"\u072c\u0721\u0718\u0719",August:"\u0710\u0712",September:"\u0710\u071d\u0720\u0718\u0720",October:"\u072c\u072b\u072a\u071d\u00a0\u0729\u0715\u071d\u0721",November:"\u072c\u072b\u072a\u071d\u00a0\u0710\u071a\u072a\u071d",December:"\u071f\u0722\u0718\u0722\u00a0\u0729\u0715\u071d\u0721", +Jan_Abbr:"\u070f\u071f\u0722\u00a0\u070f\u0712",Feb_Abbr:"\u072b\u0712\u071b",Mar_Abbr:"\u0710\u0715\u072a",Apr_Abbr:"\u0722\u071d\u0723\u0722",May_Abbr:"\u0710\u071d\u072a",Jun_Abbr:"\u071a\u0719\u071d\u072a\u0722",Jul_Abbr:"\u072c\u0721\u0718\u0719",Aug_Abbr:"\u0710\u0712",Sep_Abbr:"\u0710\u071d\u0720\u0718\u0720",Oct_Abbr:"\u070f\u072c\u072b\u00a0\u070f\u0710",Nov_Abbr:"\u070f\u072c\u072b\u00a0\u070f\u0712",Dec_Abbr:"\u070f\u071f\u0722\u00a0\u070f\u0710",AM:"\u0729.\u071b",PM:"\u0712.\u071b",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)?/":"\u071f\u0722\u0718\u0722\u00a0\u0710\u071a\u072a\u071d","/feb(ruary)?/":"\u072b\u0712\u071b", +"/mar(ch)?/":"\u0710\u0715\u072a","/apr(il)?/":"\u0722\u071d\u0723\u0722","/may/":"\u0710\u071d\u072a","/jun(e)?/":"\u071a\u0719\u071d\u072a\u0722","/jul(y)?/":"\u072c\u0721\u0718\u0719","/aug(ust)?/":"\u0710\u0712","/sep(t(ember)?)?/":"\u0710\u071d\u0720\u0718\u0720","/oct(ober)?/":"\u072c\u072b\u072a\u071d\u00a0\u0729\u0715\u071d\u0721","/nov(ember)?/":"\u072c\u072b\u072a\u071d\u00a0\u0710\u071a\u072a\u071d","/dec(ember)?/":"\u071f\u0722\u0718\u0722\u00a0\u0729\u0715\u071d\u0721","/^su(n(day)?)?/":"^\u070f(\u0710\u00a0\u070f\u0712\u072b(\u0710)?)?", +"/^mo(n(day)?)?/":"^\u070f(\u0712\u00a0\u070f\u0712\u072b(\u072b\u0712\u0710)?)?","/^tu(e(s(day)?)?)?/":"^\u070f(\u0713\u00a0\u070f\u0712\u072b(\u072b\u0712\u0710)?)?","/^we(d(nesday)?)?/":"^\u070f(\u0715\u00a0\u070f\u0712\u072b(\u0712\u072b\u0712\u0710)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u070f(\u0717\u00a0\u070f\u0712\u072b(\u072b\u0712\u0710)?)?","/^fr(i(day)?)?/":"^\u070f(\u0725\u072a\u0718\u0712(\u0710)?)?","/^sa(t(urday)?)?/":"^\u070f(\u072b\u0712(\u0710)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ta-IN"]={name:"ta-IN",englishName:"Tamil (India)",nativeName:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd (\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe)",Sunday:"\u0b9e\u0bbe\u0baf\u0bbf\u0bb1\u0bc1",Monday:"\u0ba4\u0bbf\u0b99\u0bcd\u0b95\u0bb3\u0bcd",Tuesday:"\u0b9a\u0bc6\u0bb5\u0bcd\u0bb5\u0bbe\u0baf\u0bcd",Wednesday:"\u0baa\u0bc1\u0ba4\u0ba9\u0bcd",Thursday:"\u0bb5\u0bbf\u0baf\u0bbe\u0bb4\u0ba9\u0bcd",Friday:"\u0bb5\u0bc6\u0bb3\u0bcd\u0bb3\u0bbf",Saturday:"\u0b9a\u0ba9\u0bbf",Sun:"\u0b9e\u0bbe", +Mon:"\u0ba4\u0bbf",Tue:"\u0b9a\u0bc6",Wed:"\u0baa\u0bc1",Thu:"\u0bb5\u0bbf",Fri:"\u0bb5\u0bc6",Sat:"\u0b9a",Su:"\u0b9e",Mo:"\u0ba4",Tu:"\u0b9a",We:"\u0baa",Th:"\u0bb5",Fr:"\u0bb5",Sa:"\u0b9a",S_Sun_Initial:"\u0b9e",M_Mon_Initial:"\u0ba4",T_Tue_Initial:"\u0b9a",W_Wed_Initial:"\u0baa",T_Thu_Initial:"\u0bb5",F_Fri_Initial:"\u0bb5",S_Sat_Initial:"\u0b9a",January:"\u0b9c\u0ba9\u0bb5\u0bb0\u0bbf",February:"\u0baa\u0bc6\u0baa\u0bcd\u0bb0\u0bb5\u0bb0\u0bbf",March:"\u0bae\u0bbe\u0bb0\u0bcd\u0b9a\u0bcd",April:"\u0b8f\u0baa\u0bcd\u0bb0\u0bb2\u0bcd", +May:"\u0bae\u0bc7",June:"\u0b9c\u0bc2\u0ba9\u0bcd",July:"\u0b9c\u0bc2\u0bb2\u0bc8",August:"\u0b86\u0b95\u0bb8\u0bcd\u0b9f\u0bcd",September:"\u0b9a\u0bc6\u0baa\u0bcd\u0b9f\u0bae\u0bcd\u0baa\u0bb0\u0bcd",October:"\u0b85\u0b95\u0bcd\u0b9f\u0bcb\u0baa\u0bb0\u0bcd",November:"\u0ba8\u0bb5\u0bae\u0bcd\u0baa\u0bb0\u0bcd",December:"\u0b9f\u0bbf\u0b9a\u0bae\u0bcd\u0baa\u0bb0\u0bcd",Jan_Abbr:"\u0b9c\u0ba9.",Feb_Abbr:"\u0baa\u0bc6\u0baa\u0bcd.",Mar_Abbr:"\u0bae\u0bbe\u0bb0\u0bcd.",Apr_Abbr:"\u0b8f\u0baa\u0bcd.", +May_Abbr:"\u0bae\u0bc7",Jun_Abbr:"\u0b9c\u0bc2\u0ba9\u0bcd",Jul_Abbr:"\u0b9c\u0bc2\u0bb2\u0bc8",Aug_Abbr:"\u0b86\u0b95.",Sep_Abbr:"\u0b9a\u0bc6\u0baa\u0bcd.",Oct_Abbr:"\u0b85\u0b95\u0bcd.",Nov_Abbr:"\u0ba8\u0bb5.",Dec_Abbr:"\u0b9f\u0bbf\u0b9a.",AM:"\u0b95\u0bbe\u0bb2\u0bc8",PM:"\u0bae\u0bbe\u0bb2\u0bc8",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)?/":"\u0b9c\u0ba9(.(\u0bb5\u0bb0\u0bbf)?)?","/feb(ruary)?/":"\u0baa\u0bc6\u0baa\u0bcd(.(\u0bb0\u0bb5\u0bb0\u0bbf)?)?","/mar(ch)?/":"\u0bae\u0bbe\u0bb0\u0bcd(.(\u0b9a\u0bcd)?)?","/apr(il)?/":"\u0b8f\u0baa\u0bcd(.(\u0bb0\u0bb2\u0bcd)?)?","/may/":"\u0bae\u0bc7","/jun(e)?/":"\u0b9c\u0bc2\u0ba9\u0bcd","/jul(y)?/":"\u0b9c\u0bc2\u0bb2\u0bc8", +"/aug(ust)?/":"\u0b86\u0b95(.(\u0bb8\u0bcd\u0b9f\u0bcd)?)?","/sep(t(ember)?)?/":"\u0b9a\u0bc6\u0baa\u0bcd(.(\u0b9f\u0bae\u0bcd\u0baa\u0bb0\u0bcd)?)?","/oct(ober)?/":"\u0b85\u0b95\u0bcd(.(\u0b9f\u0bcb\u0baa\u0bb0\u0bcd)?)?","/nov(ember)?/":"\u0ba8\u0bb5(.(\u0bae\u0bcd\u0baa\u0bb0\u0bcd)?)?","/dec(ember)?/":"\u0b9f\u0bbf\u0b9a(.(\u0bae\u0bcd\u0baa\u0bb0\u0bcd)?)?","/^su(n(day)?)?/":"^\u0b9e(\u0bbe(\u0baf\u0bbf\u0bb1\u0bc1)?)?","/^mo(n(day)?)?/":"^\u0ba4(\u0bbf(\u0b99\u0bcd\u0b95\u0bb3\u0bcd)?)?","/^tu(e(s(day)?)?)?/":"^\u0b9a(\u0bc6(\u0bb5\u0bcd\u0bb5\u0bbe\u0baf\u0bcd)?)?", +"/^we(d(nesday)?)?/":"^\u0baa(\u0bc1(\u0ba4\u0ba9\u0bcd)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0bb5(\u0bbf(\u0baf\u0bbe\u0bb4\u0ba9\u0bcd)?)?","/^fr(i(day)?)?/":"^\u0bb5(\u0bc6(\u0bb3\u0bcd\u0bb3\u0bbf)?)?","/^sa(t(urday)?)?/":"^\u0b9a\u0ba9\u0bbf","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?", +"/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["te-IN"]={name:"te-IN",englishName:"Telugu (India)",nativeName:"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41 (\u0c2d\u0c3e\u0c30\u0c24\u00a0\u0c26\u0c47\u0c36\u0c02)",Sunday:"\u0c06\u0c26\u0c3f\u0c35\u0c3e\u0c30\u0c02",Monday:"\u0c38\u0c4b\u0c2e\u0c35\u0c3e\u0c30\u0c02",Tuesday:"\u0c2e\u0c02\u0c17\u0c33\u0c35\u0c3e\u0c30\u0c02",Wednesday:"\u0c2c\u0c41\u0c27\u0c35\u0c3e\u0c30\u0c02",Thursday:"\u0c17\u0c41\u0c30\u0c41\u0c35\u0c3e\u0c30\u0c02",Friday:"\u0c36\u0c41\u0c15\u0c4d\u0c30\u0c35\u0c3e\u0c30\u0c02", +Saturday:"\u0c36\u0c28\u0c3f\u0c35\u0c3e\u0c30\u0c02",Sun:"\u0c06\u0c26\u0c3f.",Mon:"\u0c38\u0c4b\u0c2e.",Tue:"\u0c2e\u0c02\u0c17\u0c33.",Wed:"\u0c2c\u0c41\u0c27.",Thu:"\u0c17\u0c41\u0c30\u0c41.",Fri:"\u0c36\u0c41\u0c15\u0c4d\u0c30.",Sat:"\u0c36\u0c28\u0c3f.",Su:"\u0c06",Mo:"\u0c38",Tu:"\u0c2e",We:"\u0c2c",Th:"\u0c17",Fr:"\u0c36",Sa:"\u0c36",S_Sun_Initial:"\u0c06",M_Mon_Initial:"\u0c38",T_Tue_Initial:"\u0c2e",W_Wed_Initial:"\u0c2c",T_Thu_Initial:"\u0c17",F_Fri_Initial:"\u0c36",S_Sat_Initial:"\u0c36", +January:"\u0c1c\u0c28\u0c35\u0c30\u0c3f",February:"\u0c2b\u0c3f\u0c2c\u0c4d\u0c30\u0c35\u0c30\u0c3f",March:"\u0c2e\u0c3e\u0c30\u0c4d\u0c1a\u0c3f",April:"\u0c0f\u0c2a\u0c4d\u0c30\u0c3f\u0c32\u0c4d",May:"\u0c2e\u0c47",June:"\u0c1c\u0c42\u0c28\u0c4d",July:"\u0c1c\u0c42\u0c32\u0c48",August:"\u0c06\u0c17\u0c38\u0c4d\u0c1f\u0c41",September:"\u0c38\u0c46\u0c2a\u0c4d\u0c1f\u0c46\u0c02\u0c2c\u0c30\u0c4d",October:"\u0c05\u0c15\u0c4d\u0c1f\u0c4b\u0c2c\u0c30\u0c4d",November:"\u0c28\u0c35\u0c02\u0c2c\u0c30\u0c4d", +December:"\u0c21\u0c3f\u0c38\u0c46\u0c02\u0c2c\u0c30\u0c4d",Jan_Abbr:"\u0c1c\u0c28\u0c35\u0c30\u0c3f",Feb_Abbr:"\u0c2b\u0c3f\u0c2c\u0c4d\u0c30\u0c35\u0c30\u0c3f",Mar_Abbr:"\u0c2e\u0c3e\u0c30\u0c4d\u0c1a\u0c3f",Apr_Abbr:"\u0c0f\u0c2a\u0c4d\u0c30\u0c3f\u0c32\u0c4d",May_Abbr:"\u0c2e\u0c47",Jun_Abbr:"\u0c1c\u0c42\u0c28\u0c4d",Jul_Abbr:"\u0c1c\u0c42\u0c32\u0c48",Aug_Abbr:"\u0c06\u0c17\u0c38\u0c4d\u0c1f\u0c41",Sep_Abbr:"\u0c38\u0c46\u0c2a\u0c4d\u0c1f\u0c46\u0c02\u0c2c\u0c30\u0c4d",Oct_Abbr:"\u0c05\u0c15\u0c4d\u0c1f\u0c4b\u0c2c\u0c30\u0c4d", +Nov_Abbr:"\u0c28\u0c35\u0c02\u0c2c\u0c30\u0c4d",Dec_Abbr:"\u0c21\u0c3f\u0c38\u0c46\u0c02\u0c2c\u0c30\u0c4d",AM:"\u0c2a\u0c42\u0c30\u0c4d\u0c35\u0c3e\u0c39\u0c4d\u0c28",PM:"\u0c05\u0c2a\u0c30\u0c3e\u0c39\u0c4d\u0c28",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)?/":"\u0c1c\u0c28\u0c35\u0c30\u0c3f","/feb(ruary)?/":"\u0c2b\u0c3f\u0c2c\u0c4d\u0c30\u0c35\u0c30\u0c3f","/mar(ch)?/":"\u0c2e\u0c3e\u0c30\u0c4d\u0c1a\u0c3f","/apr(il)?/":"\u0c0f\u0c2a\u0c4d\u0c30\u0c3f\u0c32\u0c4d","/may/":"\u0c2e\u0c47","/jun(e)?/":"\u0c1c\u0c42\u0c28\u0c4d","/jul(y)?/":"\u0c1c\u0c42\u0c32\u0c48","/aug(ust)?/":"\u0c06\u0c17\u0c38\u0c4d\u0c1f\u0c41","/sep(t(ember)?)?/":"\u0c38\u0c46\u0c2a\u0c4d\u0c1f\u0c46\u0c02\u0c2c\u0c30\u0c4d", +"/oct(ober)?/":"\u0c05\u0c15\u0c4d\u0c1f\u0c4b\u0c2c\u0c30\u0c4d","/nov(ember)?/":"\u0c28\u0c35\u0c02\u0c2c\u0c30\u0c4d","/dec(ember)?/":"\u0c21\u0c3f\u0c38\u0c46\u0c02\u0c2c\u0c30\u0c4d","/^su(n(day)?)?/":"^\u0c06(\u0c26\u0c3f(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^mo(n(day)?)?/":"^\u0c38(\u0c4b\u0c2e(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^tu(e(s(day)?)?)?/":"^\u0c2e(\u0c02\u0c17\u0c33(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^we(d(nesday)?)?/":"^\u0c2c(\u0c41\u0c27(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0c17(\u0c41\u0c30\u0c41(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?", +"/^fr(i(day)?)?/":"^\u0c36(\u0c41\u0c15\u0c4d\u0c30(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^sa(t(urday)?)?/":"^\u0c36(\u0c28\u0c3f(.(\u0c35\u0c3e\u0c30\u0c02)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?", +"/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)", +"/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT", +AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["th-TH"]={name:"th-TH",englishName:"Thai (Thailand)",nativeName:"\u0e44\u0e17\u0e22 (\u0e44\u0e17\u0e22)",Sunday:"\u0e2d\u0e32\u0e17\u0e34\u0e15\u0e22\u0e4c",Monday:"\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c",Tuesday:"\u0e2d\u0e31\u0e07\u0e04\u0e32\u0e23",Wednesday:"\u0e1e\u0e38\u0e18",Thursday:"\u0e1e\u0e24\u0e2b\u0e31\u0e2a\u0e1a\u0e14\u0e35",Friday:"\u0e28\u0e38\u0e01\u0e23\u0e4c",Saturday:"\u0e40\u0e2a\u0e32\u0e23\u0e4c",Sun:"\u0e2d\u0e32.",Mon:"\u0e08.",Tue:"\u0e2d.",Wed:"\u0e1e.", +Thu:"\u0e1e\u0e24.",Fri:"\u0e28.",Sat:"\u0e2a.",Su:"\u0e2d",Mo:"\u0e08",Tu:"\u0e2d",We:"\u0e1e",Th:"\u0e1e",Fr:"\u0e28",Sa:"\u0e2a",S_Sun_Initial:"\u0e2d",M_Mon_Initial:"\u0e08",T_Tue_Initial:"\u0e2d",W_Wed_Initial:"\u0e1e",T_Thu_Initial:"\u0e1e",F_Fri_Initial:"\u0e28",S_Sat_Initial:"\u0e2a",January:"\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21",February:"\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c",March:"\u0e21\u0e35\u0e19\u0e32\u0e04\u0e21",April:"\u0e40\u0e21\u0e29\u0e32\u0e22\u0e19", +May:"\u0e1e\u0e24\u0e29\u0e20\u0e32\u0e04\u0e21",June:"\u0e21\u0e34\u0e16\u0e38\u0e19\u0e32\u0e22\u0e19",July:"\u0e01\u0e23\u0e01\u0e0e\u0e32\u0e04\u0e21",August:"\u0e2a\u0e34\u0e07\u0e2b\u0e32\u0e04\u0e21",September:"\u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19",October:"\u0e15\u0e38\u0e25\u0e32\u0e04\u0e21",November:"\u0e1e\u0e24\u0e28\u0e08\u0e34\u0e01\u0e32\u0e22\u0e19",December:"\u0e18\u0e31\u0e19\u0e27\u0e32\u0e04\u0e21",Jan_Abbr:"\u0e21.\u0e04.",Feb_Abbr:"\u0e01.\u0e1e.",Mar_Abbr:"\u0e21\u0e35.\u0e04.", +Apr_Abbr:"\u0e40\u0e21.\u0e22.",May_Abbr:"\u0e1e.\u0e04.",Jun_Abbr:"\u0e21\u0e34.\u0e22.",Jul_Abbr:"\u0e01.\u0e04.",Aug_Abbr:"\u0e2a.\u0e04.",Sep_Abbr:"\u0e01.\u0e22.",Oct_Abbr:"\u0e15.\u0e04.",Nov_Abbr:"\u0e1e.\u0e22.",Dec_Abbr:"\u0e18.\u0e04.",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)?/":"\u0e21(.(\u0e01\u0e23\u0e32\u0e04)?)?","/feb(ruary)?/":"\u0e01(.(\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c)?)?","/mar(ch)?/":"\u0e21\u0e35(.(\u0e19\u0e32\u0e04\u0e21)?)?","/apr(il)?/":"\u0e40\u0e21(.(\u0e29\u0e32\u0e22\u0e19)?)?","/may/":"\u0e1e(.(\u0e24\u0e29\u0e20\u0e32\u0e04\u0e21)?)?","/jun(e)?/":"\u0e21\u0e34(.(\u0e16\u0e38\u0e19\u0e32\u0e22\u0e19)?)?", +"/jul(y)?/":"\u0e01(.(\u0e23\u0e0e\u0e32\u0e04\u0e21)?)?","/aug(ust)?/":"\u0e2a(.(\u0e34\u0e07\u0e2b\u0e32\u0e04\u0e21)?)?","/sep(t(ember)?)?/":"\u0e01(.(\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19)?)?","/oct(ober)?/":"\u0e15(.(\u0e38\u0e25\u0e32\u0e04\u0e21)?)?","/nov(ember)?/":"\u0e1e(.(\u0e24\u0e28\u0e08\u0e34\u0e01\u0e32\u0e22\u0e19)?)?","/dec(ember)?/":"\u0e18(.(\u0e31\u0e19\u0e27\u0e32\u0e04\u0e21)?)?","/^su(n(day)?)?/":"^\u0e2d(\u0e32(.(\u0e17\u0e34\u0e15\u0e22\u0e4c)?)?)?","/^mo(n(day)?)?/":"^\u0e08((.(\u0e31\u0e19\u0e17\u0e23\u0e4c)?)?)?", +"/^tu(e(s(day)?)?)?/":"^\u0e2d((.(\u0e31\u0e07\u0e04\u0e32\u0e23)?)?)?","/^we(d(nesday)?)?/":"^\u0e1e((.(\u0e38\u0e18)?)?)?","/^th(u(r(s(day)?)?)?)?/":"^\u0e1e(\u0e24(.(\u0e2b\u0e31\u0e2a\u0e1a\u0e14\u0e35)?)?)?","/^fr(i(day)?)?/":"^\u0e28((.(\u0e38\u0e01\u0e23\u0e4c)?)?)?","/^sa(t(urday)?)?/":"^\u0e2a((.(\u0e2a\u0e32\u0e23\u0e4c)?)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["tr-TR"]={name:"tr-TR",englishName:"Turkish (Turkey)",nativeName:"T\u00fcrk\u00e7e (T\u00fcrkiye)",Sunday:"Pazar",Monday:"Pazartesi",Tuesday:"Sal\u0131",Wednesday:"\u00c7ar\u015famba",Thursday:"Per\u015fembe",Friday:"Cuma",Saturday:"Cumartesi",Sun:"Paz",Mon:"Pzt",Tue:"Sal",Wed:"\u00c7ar",Thu:"Per",Fri:"Cum",Sat:"Cmt",Su:"Pz",Mo:"Pt",Tu:"Sa",We:"\u00c7a",Th:"Pe",Fr:"Cu",Sa:"Ct",S_Sun_Initial:"P",M_Mon_Initial:"P",T_Tue_Initial:"S",W_Wed_Initial:"\u00c7",T_Thu_Initial:"P",F_Fri_Initial:"C", +S_Sat_Initial:"C",January:"Ocak",February:"\u015eubat",March:"Mart",April:"Nisan",May:"May\u0131s",June:"Haziran",July:"Temmuz",August:"A\u011fustos",September:"Eyl\u00fcl",October:"Ekim",November:"Kas\u0131m",December:"Aral\u0131k",Jan_Abbr:"Oca",Feb_Abbr:"\u015eub",Mar_Abbr:"Mar",Apr_Abbr:"Nis",May_Abbr:"May",Jun_Abbr:"Haz",Jul_Abbr:"Tem",Aug_Abbr:"A\u011fu",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)?/":"\u015fub(at)?","/mar(ch)?/":"mar(t)?","/apr(il)?/":"nis(an)?","/may/":"may(\u0131s)?","/jun(e)?/":"haz(iran)?","/jul(y)?/":"tem(muz)?", +"/aug(ust)?/":"a\u011fu(stos)?","/sep(t(ember)?)?/":"eyl(\u00fcl)?","/oct(ober)?/":"eki(m)?","/nov(ember)?/":"kas(\u0131m)?","/dec(ember)?/":"ara(l\u0131k)?","/^su(n(day)?)?/":"^pz(z(ar)?)?","/^mo(n(day)?)?/":"^pt(t(artesi)?)?","/^tu(e(s(day)?)?)?/":"^sa(l(\u0131)?)?","/^we(d(nesday)?)?/":"^\u00e7a(r(\u015famba)?)?","/^th(u(r(s(day)?)?)?)?/":"^pe(r(\u015fembe)?)?","/^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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["tt-RU"]={name:"tt-RU",englishName:"Tatar (Russia)",nativeName:"\u0422\u0430\u0442\u0430\u0440 (\u0420\u043e\u0441\u0441\u0438\u044f)",Sunday:"\u042f\u043a\u0448\u04d9\u043c\u0431\u0435",Monday:"\u0414\u04af\u0448\u04d9\u043c\u0431\u0435",Tuesday:"\u0421\u0438\u0448\u04d9\u043c\u0431\u0435",Wednesday:"\u0427\u04d9\u0440\u0448\u04d9\u043c\u0431\u0435",Thursday:"\u041f\u04d9\u043d\u0497\u0435\u0448\u04d9\u043c\u0431\u0435",Friday:"\u0496\u043e\u043c\u0433\u0430",Saturday:"\u0428\u0438\u043c\u0431\u04d9", +Sun:"\u042f\u043a\u0448",Mon:"\u0414\u04af\u0448",Tue:"\u0421\u0438\u0448",Wed:"\u0427\u04d9\u0440\u0448",Thu:"\u041f\u04d9\u043d\u0497",Fri:"\u0496\u043e\u043c",Sat:"\u0428\u0438\u043c",Su:"\u042f\u043a\u0448",Mo:"\u0414\u04af\u0448",Tu:"\u0421\u0438\u0448",We:"\u0427\u04d9\u0440\u0448",Th:"\u041f\u04d9\u043d\u0497",Fr:"\u0496\u043e\u043c",Sa:"\u0428\u0438\u043c",S_Sun_Initial:"\u042f",M_Mon_Initial:"\u0414",T_Tue_Initial:"\u0421",W_Wed_Initial:"\u0427",T_Thu_Initial:"\u041f",F_Fri_Initial:"\u0496", +S_Sat_Initial:"\u0428",January:"\u0413\u044b\u0439\u043d\u0432\u0430\u0440\u044c",February:"\u0424\u0435\u0432\u0440\u0430\u043b\u044c",March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0435\u043b\u044c",May:"\u041c\u0430\u0439",June:"\u0418\u044e\u043d\u044c",July:"\u0418\u044e\u043b\u044c",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c",October:"\u041e\u043a\u0442\u044f\u0431\u0440\u044c",November:"\u041d\u043e\u044f\u0431\u0440\u044c", +December:"\u0414\u0435\u043a\u0430\u0431\u0440\u044c",Jan_Abbr:"\u0413\u044b\u0439\u043d\u0432",Feb_Abbr:"\u0424\u0435\u0432",Mar_Abbr:"\u041c\u0430\u0440",Apr_Abbr:"\u0410\u043f\u0440",May_Abbr:"\u041c\u0430\u0439",Jun_Abbr:"\u0418\u044e\u043d",Jul_Abbr:"\u0418\u044e\u043b",Aug_Abbr:"\u0410\u0432\u0433",Sep_Abbr:"\u0421\u0435\u043d",Oct_Abbr:"\u041e\u043a\u0442",Nov_Abbr:"\u041d\u043e\u044f",Dec_Abbr:"\u0414\u0435\u043a",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)?/":"\u0433\u044b\u0439\u043d\u0432(\u0430\u0440\u044c)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0430\u043b\u044c)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0435\u043b\u044c)?", +"/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u0438\u044e\u043d(\u044c)?","/jul(y)?/":"\u0438\u044e\u043b(\u044c)?","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043d(\u0442\u044f\u0431\u0440\u044c)?","/oct(ober)?/":"\u043e\u043a\u0442(\u044f\u0431\u0440\u044c)?","/nov(ember)?/":"\u043d\u043e\u044f(\u0431\u0440\u044c)?","/dec(ember)?/":"\u0434\u0435\u043a(\u0430\u0431\u0440\u044c)?","/^su(n(day)?)?/":"^\u044f\u043a\u0448\u04d9\u043c\u0431\u0435","/^mo(n(day)?)?/":"^\u0434\u04af\u0448\u04d9\u043c\u0431\u0435", +"/^tu(e(s(day)?)?)?/":"^\u0441\u0438\u0448\u04d9\u043c\u0431\u0435","/^we(d(nesday)?)?/":"^\u0447\u04d9\u0440\u0448\u04d9\u043c\u0431\u0435","/^th(u(r(s(day)?)?)?)?/":"^\u043f\u04d9\u043d\u0497\u0435\u0448\u04d9\u043c\u0431\u0435","/^fr(i(day)?)?/":"^\u0497\u043e\u043c\u0433\u0430","/^sa(t(urday)?)?/":"^\u0448\u0438\u043c\u0431\u04d9","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["uk-UA"]={name:"uk-UA",englishName:"Ukrainian (Ukraine)",nativeName:"\u0443\u043a\u0440\u0430\u0457\u043d\u044c\u0441\u043a\u0430 (\u0423\u043a\u0440\u0430\u0457\u043d\u0430)",Sunday:"\u043d\u0435\u0434\u0456\u043b\u044f",Monday:"\u043f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a",Tuesday:"\u0432\u0456\u0432\u0442\u043e\u0440\u043e\u043a",Wednesday:"\u0441\u0435\u0440\u0435\u0434\u0430",Thursday:"\u0447\u0435\u0442\u0432\u0435\u0440",Friday:"\u043f'\u044f\u0442\u043d\u0438\u0446\u044f", +Saturday:"\u0441\u0443\u0431\u043e\u0442\u0430",Sun:"\u041d\u0434",Mon:"\u041f\u043d",Tue:"\u0412\u0442",Wed:"\u0421\u0440",Thu:"\u0427\u0442",Fri:"\u041f\u0442",Sat:"\u0421\u0431",Su:"\u041d\u0434",Mo:"\u041f\u043d",Tu:"\u0412\u0442",We:"\u0421\u0440",Th:"\u0427\u0442",Fr:"\u041f\u0442",Sa:"\u0421\u0431",S_Sun_Initial:"\u041d",M_Mon_Initial:"\u041f",T_Tue_Initial:"\u0412",W_Wed_Initial:"\u0421",T_Thu_Initial:"\u0427",F_Fri_Initial:"\u041f",S_Sat_Initial:"\u0421",January:"\u0421\u0456\u0447\u0435\u043d\u044c", +February:"\u041b\u044e\u0442\u0438\u0439",March:"\u0411\u0435\u0440\u0435\u0437\u0435\u043d\u044c",April:"\u041a\u0432\u0456\u0442\u0435\u043d\u044c",May:"\u0422\u0440\u0430\u0432\u0435\u043d\u044c",June:"\u0427\u0435\u0440\u0432\u0435\u043d\u044c",July:"\u041b\u0438\u043f\u0435\u043d\u044c",August:"\u0421\u0435\u0440\u043f\u0435\u043d\u044c",September:"\u0412\u0435\u0440\u0435\u0441\u0435\u043d\u044c",October:"\u0416\u043e\u0432\u0442\u0435\u043d\u044c",November:"\u041b\u0438\u0441\u0442\u043e\u043f\u0430\u0434", +December:"\u0413\u0440\u0443\u0434\u0435\u043d\u044c",Jan_Abbr:"\u0421\u0456\u0447",Feb_Abbr:"\u041b\u044e\u0442",Mar_Abbr:"\u0411\u0435\u0440",Apr_Abbr:"\u041a\u0432\u0456",May_Abbr:"\u0422\u0440\u0430",Jun_Abbr:"\u0427\u0435\u0440",Jul_Abbr:"\u041b\u0438\u043f",Aug_Abbr:"\u0421\u0435\u0440",Sep_Abbr:"\u0412\u0435\u0440",Oct_Abbr:"\u0416\u043e\u0432",Nov_Abbr:"\u041b\u0438\u0441",Dec_Abbr:"\u0413\u0440\u0443",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yyyy","dddd, MMMM dd, yyyy":"d MMMM yyyy' \u0440.'", +"h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"d MMMM yyyy' \u0440.' 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' \u0440.'","/jan(uary)?/":"\u0441\u0456\u0447(\u0435\u043d\u044c)?","/feb(ruary)?/":"\u043b\u044e\u0442(\u0438\u0439)?","/mar(ch)?/":"\u0431\u0435\u0440(\u0435\u0437\u0435\u043d\u044c)?","/apr(il)?/":"\u043a\u0432\u0456(\u0442\u0435\u043d\u044c)?", +"/may/":"\u0442\u0440\u0430(\u0432\u0435\u043d\u044c)?","/jun(e)?/":"\u0447\u0435\u0440(\u0432\u0435\u043d\u044c)?","/jul(y)?/":"\u043b\u0438\u043f(\u0435\u043d\u044c)?","/aug(ust)?/":"\u0441\u0435\u0440(\u043f\u0435\u043d\u044c)?","/sep(t(ember)?)?/":"\u0432\u0435\u0440(\u0435\u0441\u0435\u043d\u044c)?","/oct(ober)?/":"\u0436\u043e\u0432(\u0442\u0435\u043d\u044c)?","/nov(ember)?/":"\u043b\u0438\u0441(\u0442\u043e\u043f\u0430\u0434)?","/dec(ember)?/":"\u0433\u0440\u0443(\u0434\u0435\u043d\u044c)?", +"/^su(n(day)?)?/":"^\u043d\u0435\u0434\u0456\u043b\u044f","/^mo(n(day)?)?/":"^\u043f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a","/^tu(e(s(day)?)?)?/":"^\u0432\u0456\u0432\u0442\u043e\u0440\u043e\u043a","/^we(d(nesday)?)?/":"^\u0441\u0435\u0440\u0435\u0434\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u0447\u0435\u0442\u0432\u0435\u0440","/^fr(i(day)?)?/":"^\u043f'\u044f\u0442\u043d\u0438\u0446\u044f","/^sa(t(urday)?)?/":"^\u0441\u0443\u0431\u043e\u0442\u0430","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["ur-PK"]={name:"ur-PK",englishName:"Urdu (Islamic Republic of Pakistan)",nativeName:"\u0627\u064f\u0631\u062f\u0648 (\u067e\u0627\u06a9\u0633\u062a\u0627\u0646)",Sunday:"\u0627\u062a\u0648\u0627\u0631",Monday:"\u067e\u064a\u0631",Tuesday:"\u0645\u0646\u06af\u0644",Wednesday:"\u0628\u062f\u06be",Thursday:"\u062c\u0645\u0639\u0631\u0627\u062a",Friday:"\u062c\u0645\u0639\u0647",Saturday:"\u0647\u0641\u062a\u0647",Sun:"\u0627\u062a\u0648\u0627\u0631",Mon:"\u067e\u064a\u0631",Tue:"\u0645\u0646\u06af\u0644", +Wed:"\u0628\u062f\u06be",Thu:"\u062c\u0645\u0639\u0631\u0627\u062a",Fri:"\u062c\u0645\u0639\u0647",Sat:"\u0647\u0641\u062a\u0647",Su:"\u0627",Mo:"\u067e",Tu:"\u0645",We:"\u0628",Th:"\u062c",Fr:"\u062c",Sa:"\u0647",S_Sun_Initial:"\u0627",M_Mon_Initial:"\u067e",T_Tue_Initial:"\u0645",W_Wed_Initial:"\u0628",T_Thu_Initial:"\u062c",F_Fri_Initial:"\u062c",S_Sat_Initial:"\u0647",January:"\u062c\u0646\u0648\u0631\u0649",February:"\u0641\u0631\u0648\u0631\u0649",March:"\u0645\u0627\u0631\u0686",April:"\u0627\u067e\u0631\u064a\u0644", +May:"\u0645\u0626",June:"\u062c\u0648\u0646",July:"\u062c\u0648\u0644\u0627\u0678",August:"\u0627\u06af\u0633\u062a",September:"\u0633\u062a\u0645\u0628\u0631",October:"\u0627\u06a9\u062a\u0648\u0628\u0631",November:"\u0646\u0648\u0645\u0628\u0631",December:"\u062f\u0633\u0645\u0628\u0631",Jan_Abbr:"\u062c\u0646\u0648\u0631\u0649",Feb_Abbr:"\u0641\u0631\u0648\u0631\u0649",Mar_Abbr:"\u0645\u0627\u0631\u0686",Apr_Abbr:"\u0627\u067e\u0631\u064a\u0644",May_Abbr:"\u0645\u0626",Jun_Abbr:"\u062c\u0648\u0646", +Jul_Abbr:"\u062c\u0648\u0644\u0627\u0678",Aug_Abbr:"\u0627\u06af\u0633\u062a",Sep_Abbr:"\u0633\u062a\u0645\u0628\u0631",Oct_Abbr:"\u0627\u06a9\u062a\u0648\u0628\u0631",Nov_Abbr:"\u0646\u0648\u0645\u0628\u0631",Dec_Abbr:"\u062f\u0633\u0645\u0628\u0631",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)?/":"\u062c\u0646\u0648\u0631\u0649","/feb(ruary)?/":"\u0641\u0631\u0648\u0631\u0649","/mar(ch)?/":"\u0645\u0627\u0631\u0686","/apr(il)?/":"\u0627\u067e\u0631\u064a\u0644","/may/":"\u0645\u0626","/jun(e)?/":"\u062c\u0648\u0646","/jul(y)?/":"\u062c\u0648\u0644\u0627\u0678","/aug(ust)?/":"\u0627\u06af\u0633\u062a","/sep(t(ember)?)?/":"\u0633\u062a\u0645\u0628\u0631", +"/oct(ober)?/":"\u0627\u06a9\u062a\u0648\u0628\u0631","/nov(ember)?/":"\u0646\u0648\u0645\u0628\u0631","/dec(ember)?/":"\u062f\u0633\u0645\u0628\u0631","/^su(n(day)?)?/":"^\u0627(1)?","/^mo(n(day)?)?/":"^\u067e(1)?","/^tu(e(s(day)?)?)?/":"^\u0645(1)?","/^we(d(nesday)?)?/":"^\u0628(1)?","/^th(u(r(s(day)?)?)?)?/":"^\u062c(1)?","/^fr(i(day)?)?/":"^\u062c(1)?","/^sa(t(urday)?)?/":"^\u0647(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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["uz-Cyrl-UZ"]={name:"uz-Cyrl-UZ",englishName:"Uzbek (Cyrillic, Uzbekistan)",nativeName:"\u040e\u0437\u0431\u0435\u043a (\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d)",Sunday:"\u044f\u043a\u0448\u0430\u043d\u0431\u0430",Monday:"\u0434\u0443\u0448\u0430\u043d\u0431\u0430",Tuesday:"\u0441\u0435\u0448\u0430\u043d\u0431\u0430",Wednesday:"\u0447\u043e\u0440\u0448\u0430\u043d\u0431\u0430",Thursday:"\u043f\u0430\u0439\u0448\u0430\u043d\u0431\u0430",Friday:"\u0436\u0443\u043c\u0430", +Saturday:"\u0448\u0430\u043d\u0431\u0430",Sun:"\u044f\u043a\u0448",Mon:"\u0434\u0448",Tue:"\u0441\u0448",Wed:"\u0447\u0448",Thu:"\u043f\u0448",Fri:"\u0436",Sat:"\u0448",Su:"\u044f\u043a\u0448",Mo:"\u0434\u0448",Tu:"\u0441\u0448",We:"\u0447\u0448",Th:"\u043f\u0448",Fr:"\u0436",Sa:"\u0448",S_Sun_Initial:"\u044f",M_Mon_Initial:"\u0434",T_Tue_Initial:"\u0441",W_Wed_Initial:"\u0447",T_Thu_Initial:"\u043f",F_Fri_Initial:"\u0436",S_Sat_Initial:"\u0448",January:"\u042f\u043d\u0432\u0430\u0440",February:"\u0424\u0435\u0432\u0440\u0430\u043b", +March:"\u041c\u0430\u0440\u0442",April:"\u0410\u043f\u0440\u0435\u043b",May:"\u041c\u0430\u0439",June:"\u0418\u044e\u043d",July:"\u0418\u044e\u043b",August:"\u0410\u0432\u0433\u0443\u0441\u0442",September:"\u0421\u0435\u043d\u0442\u044f\u0431\u0440",October:"\u041e\u043a\u0442\u044f\u0431\u0440",November:"\u041d\u043e\u044f\u0431\u0440",December:"\u0414\u0435\u043a\u0430\u0431\u0440",Jan_Abbr:"\u042f\u043d\u0432",Feb_Abbr:"\u0424\u0435\u0432",Mar_Abbr:"\u041c\u0430\u0440",Apr_Abbr:"\u0410\u043f\u0440", +May_Abbr:"\u041c\u0430\u0439",Jun_Abbr:"\u0418\u044e\u043d",Jul_Abbr:"\u0418\u044e\u043b",Aug_Abbr:"\u0410\u0432\u0433",Sep_Abbr:"\u0421\u0435\u043d",Oct_Abbr:"\u041e\u043a\u0442",Nov_Abbr:"\u041d\u043e\u044f",Dec_Abbr:"\u0414\u0435\u043a",AM:"",PM:"",firstDayOfWeek:1,twoDigitYearMax:2029,mdy:"dmy","M/d/yyyy":"dd.MM.yyyy","dddd, MMMM dd, yyyy":"yyyy '\u0439\u0438\u043b' d-MMMM","h:mm tt":"HH:mm","h:mm:ss tt":"HH:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy '\u0439\u0438\u043b' 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)?/":"\u044f\u043d\u0432(\u0430\u0440)?","/feb(ruary)?/":"\u0444\u0435\u0432(\u0440\u0430\u043b)?","/mar(ch)?/":"\u043c\u0430\u0440(\u0442)?","/apr(il)?/":"\u0430\u043f\u0440(\u0435\u043b)?","/may/":"\u043c\u0430\u0439","/jun(e)?/":"\u0438\u044e\u043d","/jul(y)?/":"\u0438\u044e\u043b","/aug(ust)?/":"\u0430\u0432\u0433(\u0443\u0441\u0442)?","/sep(t(ember)?)?/":"\u0441\u0435\u043d(\u0442\u044f\u0431\u0440)?", +"/oct(ober)?/":"\u043e\u043a\u0442(\u044f\u0431\u0440)?","/nov(ember)?/":"\u043d\u043e\u044f(\u0431\u0440)?","/dec(ember)?/":"\u0434\u0435\u043a(\u0430\u0431\u0440)?","/^su(n(day)?)?/":"^\u044f\u043a\u0448\u0430\u043d\u0431\u0430","/^mo(n(day)?)?/":"^\u0434\u0443\u0448\u0430\u043d\u0431\u0430","/^tu(e(s(day)?)?)?/":"^\u0441\u0435\u0448\u0430\u043d\u0431\u0430","/^we(d(nesday)?)?/":"^\u0447\u043e\u0440\u0448\u0430\u043d\u0431\u0430","/^th(u(r(s(day)?)?)?)?/":"^\u043f\u0430\u0439\u0448\u0430\u043d\u0431\u0430", +"/^fr(i(day)?)?/":"^\u0436\u0443\u043c\u0430","/^sa(t(urday)?)?/":"^\u0448\u0430\u043d\u0431\u0430","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?", +"/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT", +CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["vi-VN"]={name:"vi-VN",englishName:"Vietnamese (Vietnam)",nativeName:"Ti\u00ea\u0301ng Vi\u00ea\u0323t (Vi\u00ea\u0323t Nam)",Sunday:"Chu\u0309 Nh\u00e2\u0323t",Monday:"Th\u01b0\u0301 Hai",Tuesday:"Th\u01b0\u0301 Ba",Wednesday:"Th\u01b0\u0301 T\u01b0",Thursday:"Th\u01b0\u0301 N\u0103m",Friday:"Th\u01b0\u0301 Sa\u0301u",Saturday:"Th\u01b0\u0301 Ba\u0309y",Sun:"CN",Mon:"Hai",Tue:"Ba",Wed:"T\u01b0",Thu:"N\u0103m",Fri:"Sa\u0301u",Sat:"Ba\u0309y",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:"Tha\u0301ng Gi\u00eang",February:"Tha\u0301ng Hai",March:"Tha\u0301ng Ba",April:"Tha\u0301ng T\u01b0",May:"Tha\u0301ng N\u0103m",June:"Tha\u0301ng Sa\u0301u",July:"Tha\u0301ng Ba\u0309y",August:"Tha\u0301ng Ta\u0301m",September:"Tha\u0301ng Chi\u0301n",October:"Tha\u0301ng M\u01b0\u01a1\u0300i",November:"Tha\u0301ng M\u01b0\u01a1\u0300i M\u00f4\u0323t", +December:"Tha\u0301ng M\u01b0\u01a1\u0300i 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)?/":"tha\u0301ng gi\u00eang","/feb(ruary)?/":"tha\u0301ng hai","/mar(ch)?/":"tha\u0301ng ba","/apr(il)?/":"tha\u0301ng t\u01b0","/may/":"tha\u0301ng n\u0103m","/jun(e)?/":"tha\u0301ng sa\u0301u","/jul(y)?/":"tha\u0301ng ba\u0309y","/aug(ust)?/":"tha\u0301ng ta\u0301m","/sep(t(ember)?)?/":"tha\u0301ng chi\u0301n","/oct(ober)?/":"tha\u0301ng m\u01b0\u01a1\u0300i", +"/nov(ember)?/":"tha\u0301ng m\u01b0\u01a1\u0300i m\u00f4\u0323t","/dec(ember)?/":"tha\u0301ng m\u01b0\u01a1\u0300i hai","/^su(n(day)?)?/":"^c(n(u\u0309 nh\u00e2\u0323t)?)?","/^mo(n(day)?)?/":"^h(ai(\u0301 hai)?)?","/^tu(e(s(day)?)?)?/":"^b(a(\u01b0\u0301 ba)?)?","/^we(d(nesday)?)?/":"^t(\u01b0(\u01b0\u0301 t\u01b0)?)?","/^th(u(r(s(day)?)?)?)?/":"^n(\u0103m(\u0301 n\u0103m)?)?","/^fr(i(day)?)?/":"^s(a\u0301u( sa\u0301u)?)?","/^sa(t(urday)?)?/":"^b(a\u0309y( ba\u0309y)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["zh-CN"]={name:"zh-CN",englishName:"Chinese (People's Republic of China)",nativeName:"\u4e2d\u6587(\u4e2d\u534e\u4eba\u6c11\u5171\u548c\u56fd)",Sunday:"\u661f\u671f\u65e5",Monday:"\u661f\u671f\u4e00",Tuesday:"\u661f\u671f\u4e8c",Wednesday:"\u661f\u671f\u4e09",Thursday:"\u661f\u671f\u56db",Friday:"\u661f\u671f\u4e94",Saturday:"\u661f\u671f\u516d",Sun:"\u65e5",Mon:"\u4e00",Tue:"\u4e8c",Wed:"\u4e09",Thu:"\u56db",Fri:"\u4e94",Sat:"\u516d",Su:"\u65e5",Mo:"\u4e00",Tu:"\u4e8c",We:"\u4e09", +Th:"\u56db",Fr:"\u4e94",Sa:"\u516d",S_Sun_Initial:"\u65e5",M_Mon_Initial:"\u4e00",T_Tue_Initial:"\u4e8c",W_Wed_Initial:"\u4e09",T_Thu_Initial:"\u56db",F_Fri_Initial:"\u4e94",S_Sat_Initial:"\u516d",January:"\u4e00\u6708",February:"\u4e8c\u6708",March:"\u4e09\u6708",April:"\u56db\u6708",May:"\u4e94\u6708",June:"\u516d\u6708",July:"\u4e03\u6708",August:"\u516b\u6708",September:"\u4e5d\u6708",October:"\u5341\u6708",November:"\u5341\u4e00\u6708",December:"\u5341\u4e8c\u6708",Jan_Abbr:"\u4e00\u6708",Feb_Abbr:"\u4e8c\u6708", +Mar_Abbr:"\u4e09\u6708",Apr_Abbr:"\u56db\u6708",May_Abbr:"\u4e94\u6708",Jun_Abbr:"\u516d\u6708",Jul_Abbr:"\u4e03\u6708",Aug_Abbr:"\u516b\u6708",Sep_Abbr:"\u4e5d\u6708",Oct_Abbr:"\u5341\u6708",Nov_Abbr:"\u5341\u4e00\u6708",Dec_Abbr:"\u5341\u4e8c\u6708",AM:"\u4e0a\u5348",PM:"\u4e0b\u5348",firstDayOfWeek:0,twoDigitYearMax:2029,mdy:"ymd","M/d/yyyy":"yyyy/M/d","dddd, MMMM dd, yyyy":"yyyy'\u5e74'M'\u6708'd'\u65e5'","h:mm tt":"H:mm","h:mm:ss tt":"H:mm:ss","dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy'\u5e74'M'\u6708'd'\u65e5' 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'\u6708'd'\u65e5'","MMMM, yyyy":"yyyy'\u5e74'M'\u6708'","/jan(uary)?/":"\u4e00\u6708","/feb(ruary)?/":"\u4e8c\u6708","/mar(ch)?/":"\u4e09\u6708","/apr(il)?/":"\u56db\u6708","/may/":"\u4e94\u6708","/jun(e)?/":"\u516d\u6708","/jul(y)?/":"\u4e03\u6708","/aug(ust)?/":"\u516b\u6708","/sep(t(ember)?)?/":"\u4e5d\u6708","/oct(ober)?/":"\u5341\u6708", +"/nov(ember)?/":"\u5341\u4e00\u6708","/dec(ember)?/":"\u5341\u4e8c\u6708","/^su(n(day)?)?/":"^\u661f\u671f\u65e5","/^mo(n(day)?)?/":"^\u661f\u671f\u4e00","/^tu(e(s(day)?)?)?/":"^\u661f\u671f\u4e8c","/^we(d(nesday)?)?/":"^\u661f\u671f\u4e09","/^th(u(r(s(day)?)?)?)?/":"^\u661f\u671f\u56db","/^fr(i(day)?)?/":"^\u661f\u671f\u4e94","/^sa(t(urday)?)?/":"^\u661f\u671f\u516d","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)", +"/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)", +"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET", +CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["zh-HK"]={name:"zh-HK",englishName:"Chinese (Hong Kong S.A.R.)",nativeName:"\u4e2d\u6587(\u9999\u6e2f\u7279\u522b\u884c\u653f\u5340)",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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["zh-MO"]={name:"zh-MO",englishName:"Chinese (Macao S.A.R.)",nativeName:"\u4e2d\u6587(\u6fb3\u9580\u7279\u522b\u884c\u653f\u5340)",Sunday:"\u661f\u671f\u65e5",Monday:"\u661f\u671f\u4e00",Tuesday:"\u661f\u671f\u4e8c",Wednesday:"\u661f\u671f\u4e09",Thursday:"\u661f\u671f\u56db",Friday:"\u661f\u671f\u4e94",Saturday:"\u661f\u671f\u516d",Sun:"\u661f\u671f\u65e5",Mon:"\u661f\u671f\u4e00",Tue:"\u661f\u671f\u4e8c",Wed:"\u661f\u671f\u4e09",Thu:"\u661f\u671f\u56db",Fri:"\u661f\u671f\u4e94", +Sat:"\u661f\u671f\u516d",Su:"\u65e5",Mo:"\u4e00",Tu:"\u4e8c",We:"\u4e09",Th:"\u56db",Fr:"\u4e94",Sa:"\u516d",S_Sun_Initial:"\u65e5",M_Mon_Initial:"\u4e00",T_Tue_Initial:"\u4e8c",W_Wed_Initial:"\u4e09",T_Thu_Initial:"\u56db",F_Fri_Initial:"\u4e94",S_Sat_Initial:"\u516d",January:"\u4e00\u6708",February:"\u4e8c\u6708",March:"\u4e09\u6708",April:"\u56db\u6708",May:"\u4e94\u6708",June:"\u516d\u6708",July:"\u4e03\u6708",August:"\u516b\u6708",September:"\u4e5d\u6708",October:"\u5341\u6708",November:"\u5341\u4e00\u6708", +December:"\u5341\u4e8c\u6708",Jan_Abbr:"\u4e00\u6708",Feb_Abbr:"\u4e8c\u6708",Mar_Abbr:"\u4e09\u6708",Apr_Abbr:"\u56db\u6708",May_Abbr:"\u4e94\u6708",Jun_Abbr:"\u516d\u6708",Jul_Abbr:"\u4e03\u6708",Aug_Abbr:"\u516b\u6708",Sep_Abbr:"\u4e5d\u6708",Oct_Abbr:"\u5341\u6708",Nov_Abbr:"\u5341\u4e00\u6708",Dec_Abbr:"\u5341\u4e8c\u6708",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)?/":"\u4e00\u6708","/feb(ruary)?/":"\u4e8c\u6708","/mar(ch)?/":"\u4e09\u6708","/apr(il)?/":"\u56db\u6708","/may/":"\u4e94\u6708","/jun(e)?/":"\u516d\u6708","/jul(y)?/":"\u4e03\u6708","/aug(ust)?/":"\u516b\u6708","/sep(t(ember)?)?/":"\u4e5d\u6708","/oct(ober)?/":"\u5341\u6708","/nov(ember)?/":"\u5341\u4e00\u6708", +"/dec(ember)?/":"\u5341\u4e8c\u6708","/^su(n(day)?)?/":"^\u661f\u671f\u65e5","/^mo(n(day)?)?/":"^\u661f\u671f\u4e00","/^tu(e(s(day)?)?)?/":"^\u661f\u671f\u4e8c","/^we(d(nesday)?)?/":"^\u661f\u671f\u4e09","/^th(u(r(s(day)?)?)?)?/":"^\u661f\u671f\u56db","/^fr(i(day)?)?/":"^\u661f\u671f\u4e94","/^sa(t(urday)?)?/":"^\u661f\u671f\u516d","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["zh-SG"]={name:"zh-SG",englishName:"Chinese (Singapore)",nativeName:"\u4e2d\u6587(\u65b0\u52a0\u5761)",Sunday:"\u661f\u671f\u65e5",Monday:"\u661f\u671f\u4e00",Tuesday:"\u661f\u671f\u4e8c",Wednesday:"\u661f\u671f\u4e09",Thursday:"\u661f\u671f\u56db",Friday:"\u661f\u671f\u4e94",Saturday:"\u661f\u671f\u516d",Sun:"\u661f\u671f\u65e5",Mon:"\u661f\u671f\u4e00",Tue:"\u661f\u671f\u4e8c",Wed:"\u661f\u671f\u4e09",Thu:"\u661f\u671f\u56db",Fri:"\u661f\u671f\u4e94",Sat:"\u661f\u671f\u516d", +Su:"\u65e5",Mo:"\u4e00",Tu:"\u4e8c",We:"\u4e09",Th:"\u56db",Fr:"\u4e94",Sa:"\u516d",S_Sun_Initial:"\u65e5",M_Mon_Initial:"\u4e00",T_Tue_Initial:"\u4e8c",W_Wed_Initial:"\u4e09",T_Thu_Initial:"\u56db",F_Fri_Initial:"\u4e94",S_Sat_Initial:"\u516d",January:"\u4e00\u6708",February:"\u4e8c\u6708",March:"\u4e09\u6708",April:"\u56db\u6708",May:"\u4e94\u6708",June:"\u516d\u6708",July:"\u4e03\u6708",August:"\u516b\u6708",September:"\u4e5d\u6708",October:"\u5341\u6708",November:"\u5341\u4e00\u6708",December:"\u5341\u4e8c\u6708", +Jan_Abbr:"\u4e00\u6708",Feb_Abbr:"\u4e8c\u6708",Mar_Abbr:"\u4e09\u6708",Apr_Abbr:"\u56db\u6708",May_Abbr:"\u4e94\u6708",Jun_Abbr:"\u516d\u6708",Jul_Abbr:"\u4e03\u6708",Aug_Abbr:"\u516b\u6708",Sep_Abbr:"\u4e5d\u6708",Oct_Abbr:"\u5341\u6708",Nov_Abbr:"\u5341\u4e00\u6708",Dec_Abbr:"\u5341\u4e8c\u6708",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)?/":"\u4e00\u6708","/feb(ruary)?/":"\u4e8c\u6708","/mar(ch)?/":"\u4e09\u6708","/apr(il)?/":"\u56db\u6708","/may/":"\u4e94\u6708","/jun(e)?/":"\u516d\u6708","/jul(y)?/":"\u4e03\u6708","/aug(ust)?/":"\u516b\u6708","/sep(t(ember)?)?/":"\u4e5d\u6708","/oct(ober)?/":"\u5341\u6708","/nov(ember)?/":"\u5341\u4e00\u6708", +"/dec(ember)?/":"\u5341\u4e8c\u6708","/^su(n(day)?)?/":"^\u661f\u671f\u65e5","/^mo(n(day)?)?/":"^\u661f\u671f\u4e00","/^tu(e(s(day)?)?)?/":"^\u661f\u671f\u4e8c","/^we(d(nesday)?)?/":"^\u661f\u671f\u4e09","/^th(u(r(s(day)?)?)?)?/":"^\u661f\u671f\u56db","/^fr(i(day)?)?/":"^\u661f\u671f\u4e94","/^sa(t(urday)?)?/":"^\u661f\u671f\u516d","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", +"/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", +"/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", +CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +Date.CultureStrings=Date.CultureStrings||{}; +Date.CultureStrings["zh-TW"]={name:"zh-TW",englishName:"Chinese (Taiwan)",nativeName:"\u4e2d\u6587(\u53f0\u7063)",Sunday:"\u661f\u671f\u65e5",Monday:"\u661f\u671f\u4e00",Tuesday:"\u661f\u671f\u4e8c",Wednesday:"\u661f\u671f\u4e09",Thursday:"\u661f\u671f\u56db",Friday:"\u661f\u671f\u4e94",Saturday:"\u661f\u671f\u516d",Sun:"\u661f\u671f\u65e5",Mon:"\u661f\u671f\u4e00",Tue:"\u661f\u671f\u4e8c",Wed:"\u661f\u671f\u4e09",Thu:"\u661f\u671f\u56db",Fri:"\u661f\u671f\u4e94",Sat:"\u661f\u671f\u516d",Su:"\u65e5", +Mo:"\u4e00",Tu:"\u4e8c",We:"\u4e09",Th:"\u56db",Fr:"\u4e94",Sa:"\u516d",S_Sun_Initial:"\u65e5",M_Mon_Initial:"\u4e00",T_Tue_Initial:"\u4e8c",W_Wed_Initial:"\u4e09",T_Thu_Initial:"\u56db",F_Fri_Initial:"\u4e94",S_Sat_Initial:"\u516d",January:"\u4e00\u6708",February:"\u4e8c\u6708",March:"\u4e09\u6708",April:"\u56db\u6708",May:"\u4e94\u6708",June:"\u516d\u6708",July:"\u4e03\u6708",August:"\u516b\u6708",September:"\u4e5d\u6708",October:"\u5341\u6708",November:"\u5341\u4e00\u6708",December:"\u5341\u4e8c\u6708", +Jan_Abbr:"\u4e00\u6708",Feb_Abbr:"\u4e8c\u6708",Mar_Abbr:"\u4e09\u6708",Apr_Abbr:"\u56db\u6708",May_Abbr:"\u4e94\u6708",Jun_Abbr:"\u516d\u6708",Jul_Abbr:"\u4e03\u6708",Aug_Abbr:"\u516b\u6708",Sep_Abbr:"\u4e5d\u6708",Oct_Abbr:"\u5341\u6708",Nov_Abbr:"\u5341\u4e00\u6708",Dec_Abbr:"\u5341\u4e8c\u6708",AM:"\u4e0a\u5348",PM:"\u4e0b\u5348",firstDayOfWeek:0,twoDigitYearMax:2029,mdy:"ymd","M/d/yyyy":"yyyy/M/d","dddd, MMMM dd, yyyy":"yyyy'\u5e74'M'\u6708'd'\u65e5'","h:mm tt":"tt hh:mm","h:mm:ss tt":"tt hh:mm:ss", +"dddd, MMMM dd, yyyy h:mm:ss tt":"yyyy'\u5e74'M'\u6708'd'\u65e5' 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'\u6708'd'\u65e5'","MMMM, yyyy":"yyyy'\u5e74'M'\u6708'","/jan(uary)?/":"\u4e00\u6708","/feb(ruary)?/":"\u4e8c\u6708","/mar(ch)?/":"\u4e09\u6708","/apr(il)?/":"\u56db\u6708","/may/":"\u4e94\u6708","/jun(e)?/":"\u516d\u6708","/jul(y)?/":"\u4e03\u6708","/aug(ust)?/":"\u516b\u6708", +"/sep(t(ember)?)?/":"\u4e5d\u6708","/oct(ober)?/":"\u5341\u6708","/nov(ember)?/":"\u5341\u4e00\u6708","/dec(ember)?/":"\u5341\u4e8c\u6708","/^su(n(day)?)?/":"^\u661f\u671f\u65e5","/^mo(n(day)?)?/":"^\u661f\u671f\u4e00","/^tu(e(s(day)?)?)?/":"^\u661f\u671f\u4e8c","/^we(d(nesday)?)?/":"^\u661f\u671f\u4e09","/^th(u(r(s(day)?)?)?)?/":"^\u661f\u671f\u56db","/^fr(i(day)?)?/":"^\u661f\u671f\u4e94","/^sa(t(urday)?)?/":"^\u661f\u671f\u516d","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?", +"/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)","/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)", +"/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)","/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST", +PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT",CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +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"; +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + * @copyright 2014 Gregory Wild-Smith + * @license MIT + * @homepage https://github.com/abritinthebay/datejs + */ +/* + 2014 Gregory Wild-Smith + @license MIT + @homepage https://github.com/abritinthebay/datejs +*/ +(function(){var h=Date,f=Date.CultureStrings?Date.CultureStrings.lang:null,d={},c={getFromKey:function(a,b){var e;e=Date.CultureStrings&&Date.CultureStrings[b]&&Date.CultureStrings[b][a]?Date.CultureStrings[b][a]:c.buildFromDefault(a);"/"===a.charAt(0)&&(e=c.buildFromRegex(a,b));return e},getFromObjectValues:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[e]=c.getFromKey(a[e],b));return g},getFromObjectKeys:function(a,b){var e,g={};for(e in a)a.hasOwnProperty(e)&&(g[c.getFromKey(e,b)]= +a[e]);return g},getFromArray:function(a,b){for(var e=[],g=0;gb?1:0;throw new TypeError(a+" - "+b);};h.equals= +function(a,b){return 0===a.compareTo(b)};h.getDayName=function(a){return Date.CultureInfo.dayNames[a]};h.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,e=Date.CultureInfo.abbreviatedDayNames,g=Date.CultureInfo.shortestDayNames;a=a.toLowerCase();for(var m=0;me?!1:!0};h.validateMillisecond=function(a){return c(a,0,999,"millisecond")};h.validateSecond=function(a){return c(a,0,59,"second")};h.validateMinute=function(a){return c(a,0, +59,"minute")};h.validateHour=function(a){return c(a,0,23,"hour")};h.validateDay=function(a,b,e){return void 0===b||null===b||void 0===e||null===e?!1:c(a,1,h.getDaysInMonth(b,e),"day")};h.validateWeek=function(a){return c(a,0,53,"week")};h.validateMonth=function(a){return c(a,0,11,"month")};h.validateYear=function(a){return c(a,-271822,275760,"year")};h.validateTimezone=function(a){return 1==={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}[a]};h.validateTimezoneOffset=function(a){return-841a}})(); +(function(){var h=Date,f=h.prototype,d=function(a,b){b||(b=2);return("000"+a).slice(-1*b)},c=function(a){var b={},e=this,g,c;c=function(b,g,c){if("day"===b){b=void 0!==a.month?a.month:e.getMonth();var d=void 0!==a.year?a.year:e.getFullYear();return h[g](c,d,b)}return h[g](c)};for(g in a)if(hasOwnProperty.call(a,g)){var d="validate"+g.charAt(0).toUpperCase()+g.slice(1);h[d]&&null!==a[g]&&c(g,d,a[g])&&(b[g]=a[g])}return b};f.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0); +this.setMilliseconds(0);return this};f.setTimeToNow=function(){var a=new Date;this.setHours(a.getHours());this.setMinutes(a.getMinutes());this.setSeconds(a.getSeconds());this.setMilliseconds(a.getMilliseconds());return this};f.clone=function(){return new Date(this.getTime())};f.compareTo=function(a){return Date.compare(this,a)};f.equals=function(a){return Date.equals(this,void 0!==a?a:new Date)};f.between=function(a,b){return this.getTime()>=a.getTime()&&this.getTime()<=b.getTime()};f.isAfter=function(a){return 1=== +this.compareTo(a||new Date)};f.isBefore=function(a){return-1===this.compareTo(a||new Date)};f.isToday=f.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};f.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};f.addSeconds=function(a){return a?this.addMilliseconds(1E3*a):this};f.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};f.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};f.addDays= +function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};f.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),e=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5b)this.moveToLastDayOfMonth(), +this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var e=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};f.getElapsed=function(a){return(a||new Date)-this};f.set=function(a){a=c.call(this,a);for(var b in a)if(hasOwnProperty.call(a, +b)){var e=b.charAt(0).toUpperCase()+b.slice(1),g,d;"week"!==b&&"month"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&(e+="s");g="add"+e;d="get"+e;"month"===b?g+="s":"year"===b&&(d="getFullYear");if("day"!==b&&"timezone"!==b&&"timezoneOffset"!==b&&"week"!==b&&"hour"!==b)this[g](a[b]-this[d]());else if("timezone"===b||"timezoneOffset"===b||"week"===b||"hour"===b)this["set"+e](a[b])}a.day&&this.addDays(a.day-this.getDate());return this};f.moveToFirstDayOfMonth=function(){return this.set({day:1})};f.moveToLastDayOfMonth= +function(){return this.set({day:h.getDaysInMonth(this.getFullYear(),this.getMonth())})};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}},e=function(a){var b=Date.CultureInfo.formatPatterns;switch(a){case "d":return this.toString(b.shortDate);case "D":return this.toString(b.longDate);case "F":return this.toString(b.fullDateTime);case "m":return this.toString(b.monthDay);case "r":case "R":return a=this.clone().addMinutes(this.getTimezoneOffset()), +a.toString(b.rfc1123)+" GMT";case "s":return this.toString(b.sortableDateTime);case "t":return this.toString(b.shortTime);case "T":return this.toString(b.longTime);case "u":return a=this.clone().addMinutes(this.getTimezoneOffset()),a.toString(b.universalSortableDateTime);case "y":return this.toString(b.yearMonth);default:return!1}},g=function(a){return function(e){if("\\"===e.charAt(0))return e.replace("\\","");switch(e){case "hh":return d(13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()- +12);case "h":return 13>a.getHours()?0===a.getHours()?12:a.getHours():a.getHours()-12;case "HH":return d(a.getHours());case "H":return a.getHours();case "mm":return d(a.getMinutes());case "m":return a.getMinutes();case "ss":return d(a.getSeconds());case "s":return a.getSeconds();case "yyyy":return d(a.getFullYear(),4);case "yy":return d(a.getFullYear());case "y":return a.getFullYear();case "E":case "dddd":return Date.CultureInfo.dayNames[a.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[a.getDay()]; +case "dd":return d(a.getDate());case "d":return a.getDate();case "MMMM":return Date.CultureInfo.monthNames[a.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[a.getMonth()];case "MM":return d(a.getMonth()+1);case "M":return a.getMonth()+1;case "t":return 12>a.getHours()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>a.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(a.getDate()); +case "W":return a.getWeek();case "WW":return a.getISOWeek();case "Q":return"Q"+a.getQuarter();case "q":return String(a.getQuarter());case "z":return a.getTimezone();case "Z":case "X":return Date.getTimezoneOffset(a.getTimezone());case "ZZ":return-60*a.getTimezoneOffset();case "u":return a.getDay();case "L":return h.isLeapYear(a.getFullYear())?1:0;case "B":return"@"+(a.getUTCSeconds()+60*a.getUTCMinutes()+3600*(a.getUTCHours()+1))/86.4;default:return e}}};f.toString=function(a,b){if(!b&&a&&1===a.length&& +(output=e.call(this,a)))return output;var c=g(this);return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,c).replace(/\[|\]/g,""):this._toString()}})(); +(function(){var h=Date,f=h.prototype,d=Number.prototype;f._orient=1;f._nth=null;f._is=!1;f._same=!1;f._isSecond=!1;d._dateElement="days";f.next=function(){this._move=!0;this._orient=1;return this};h.next=function(){return h.today().next()};f.last=f.prev=f.previous=function(){this._move=!0;this._orient=-1;return this};h.last=h.prev=h.previous=function(){return h.today().last()};f.is=function(){this._is=!0;return this};f.same=function(){this._same=!0;this._isSecond=!1;return this};f.today=function(){return this.same().day()}; +f.weekday=function(){return this._nth?m("Weekday").call(this):this._move?this.addWeekdays(this._orient):this._is?(this._is=!1,!this.is().sat()&&!this.is().sun()):!1};f.weekend=function(){return this._is?(this._is=!1,this.is().sat()||this.is().sun()):!1};f.at=function(a){return"string"===typeof a?h.parse(this.toString("d")+" "+a):this.set(a)};d.fromNow=d.after=function(a){var b={};b[this._dateElement]=this;return(a?a.clone():new Date).add(b)};d.ago=d.before=function(a){var b={};b["s"!==this._dateElement[this._dateElement.length- +1]?this._dateElement+"s":this._dateElement]=-1*this;return(a?a.clone():new Date).add(b)};var c="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),a="january february march april may june july august september october november december".split(/\s/),b="Millisecond Second Minute Hour Day Week Month Year Quarter Weekday".split(/\s/),e="Milliseconds Seconds Minutes Hours Date Week Month FullYear Quarter".split(/\s/),g="final first second third fourth fifth".split(/\s/);f.toObject=function(){for(var a= +{},g=0;ge)throw new RangeError(h.getDayName(a)+ +" does not occur "+b+" times in the month of "+h.getMonthName(e.getMonth())+" "+e.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},k=function(a,b,e){for(var g=0;ga.length&&0>a.indexOf(".")&&0>a.indexOf("/"))return e.year= +a,h.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bp;p++){var q=c.shift();q&&(delete e[q],g--)}try{f=e[l]=e[l]||a.call(this,l)}catch(s){f=e[l]=s}g++;c.push(l);if(f instanceof h.Exception)throw f;return f}},any:function(){var a=arguments;return function(e){for(var g=null,c=0;cthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"===this.meridian&&12>this.hour?this.hour+=12:"a"===this.meridian&&12===this.hour&&(this.hour= +0)}};h.Translator={hour:function(c){return function(){this.hour=Number(c)}},minute:function(c){return function(){this.minute=Number(c)}},second:function(c){return function(){this.second=Number(c)}},secondAndMillisecond:function(c){return function(){var a=c.match(/^([0-5][0-9])\.([0-9]{1,3})/);this.second=Number(a[1]);this.millisecond=Number(a[2])}},meridian:function(c){return function(){this.meridian=c.slice(0,1).toLowerCase()}},timezone:function(c){return function(){var a=c.replace(/[^\d\+\-]/g, +"");a.length?this.timezoneOffset=Number(a):this.timezone=c.toLowerCase()}},day:function(c){var a=c[0];return function(){this.day=Number(a.match(/\d+/)[0]);if(1>this.day)throw"invalid day";}},month:function(c){return function(){this.month=3===c.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(c)/4:Number(c)-1;if(0>this.month)throw"invalid month";}},year:function(c){return function(){var a=Number(c);this.year=2h.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");c=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&c.setFullYear(this.year);this.timezone?c.set({timezone:this.timezone}):this.timezoneOffset&&c.set({timezoneOffset:this.timezoneOffset});return c},finish:function(c){var a,b,e;c=c instanceof Array?f(c):[c];if(0===c.length)return null; +for(a=0;ac?-1:1,k=Math.abs(c);this.setDays(Math.floor(k/864E5)*h);k%=864E5;this.setHours(Math.floor(k/36E5)*h);k%=36E5;this.setMinutes(Math.floor(k/6E4)*h);k%=6E4;this.setSeconds(Math.floor(k/1E3)*h);this.setMilliseconds(k%1E3*h)}else this.set(c,a,b,e,f);this.getTotalMilliseconds=function(){return 864E5*this.getDays()+ +36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)};this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/ +1E3)};this.addDays=function(a){return new d(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new d(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new d(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new d(this.getTotalMilliseconds()+1E3*a)};this.addMilliseconds=function(a){return new d(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g, +function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds();case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator: +Date.CultureInfo.pmDesignator}}):this._toString()};return this};(function(c,a){for(var b=0;bc;)f();else for(;bp?1:-1;this.dates={start:arguments[0].clone(),end:arguments[1].clone()};d(q,l,p,this);var s=!1===(l.isDaylightSavingTime()===p.isDaylightSavingTime());s&&1===q?l.addHours(-1):s&&l.addHours(1);l=p-l;0!==l&&(l=new TimeSpan(l),this.set(this.years,this.months,l.getDays(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()))}return this};(function(a,b){for(var c=0;c + */ +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. + */ \ No newline at end of file diff --git a/vendors/DateJS/package.json b/vendors/DateJS/package.json new file mode 100644 index 0000000..d509dff --- /dev/null +++ b/vendors/DateJS/package.json @@ -0,0 +1,52 @@ +{ + "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" +} diff --git a/vendors/DateJS/reports/coverage.json b/vendors/DateJS/reports/coverage.json new file mode 100644 index 0000000..d939bd9 --- /dev/null +++ b/vendors/DateJS/reports/coverage.json @@ -0,0 +1 @@ +{"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}}]}}}} \ No newline at end of file diff --git a/vendors/DateJS/reports/lcov-report/core/core-prototypes.js.html b/vendors/DateJS/reports/lcov-report/core/core-prototypes.js.html new file mode 100644 index 0000000..e752a99 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/core-prototypes.js.html @@ -0,0 +1,2626 @@ + + + + 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();
+	};
+ 
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/core.js.html b/vendors/DateJS/reports/lcov-report/core/core.js.html new file mode 100644 index 0000000..df6665a --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/core.js.html @@ -0,0 +1,1351 @@ + + + + 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);
+	};
+ 
+}());
+ 
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/extras.js.html b/vendors/DateJS/reports/lcov-report/core/extras.js.html new file mode 100644 index 0000000..ae2dfa2 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/extras.js.html @@ -0,0 +1,1261 @@ + + + + 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;
+	}
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/format_parser.js.html b/vendors/DateJS/reports/lcov-report/core/format_parser.js.html new file mode 100644 index 0000000..fe2dcb8 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/format_parser.js.html @@ -0,0 +1,1462 @@ + + + + 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();
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/i18n.js.html b/vendors/DateJS/reports/lcov-report/core/i18n.js.html new file mode 100644 index 0000000..dbd48ae --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/i18n.js.html @@ -0,0 +1,1567 @@ + + + + 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
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/index.html b/vendors/DateJS/reports/lcov-report/core/index.html new file mode 100644 index 0000000..b2064fd --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/index.html @@ -0,0 +1,493 @@ + + + + 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/
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
core-prototypes.js95.1%(291 / 306)83.33%(195 / 234)100%(50 / 50)96.28%(285 / 296)
core.js96.77%(120 / 124)90.11%(82 / 91)91.18%(31 / 34)98.36%(120 / 122)
extras.js61.76%(42 / 68)33.33%(15 / 45)92.31%(12 / 13)61.76%(42 / 68)
format_parser.js96.95%(159 / 164)86.13%(118 / 137)94.29%(33 / 35)96.95%(159 / 164)
i18n.js95.45%(147 / 154)75%(69 / 92)94.12%(32 / 34)95.45%(147 / 154)
parser.js72.34%(34 / 47)87.5%(28 / 32)62.5%(5 / 8)72.34%(34 / 47)
parsing_grammar.js91.59%(98 / 107)56.25%(9 / 16)96.55%(28 / 29)91.59%(98 / 107)
parsing_operators.js72.12%(150 / 208)65%(52 / 80)70.45%(31 / 44)72.12%(150 / 208)
parsing_translator.js79.7%(161 / 202)71.43%(165 / 231)87.5%(28 / 32)79.7%(161 / 202)
sugarpak.js96.62%(143 / 148)82.86%(58 / 70)100%(30 / 30)96.58%(141 / 146)
time_period.js33.33%(21 / 63)2.7%(1 / 37)36.36%(4 / 11)33.33%(21 / 63)
time_span.js20.65%(19 / 92)1.72%(1 / 58)16%(4 / 25)20.65%(19 / 92)
+
+
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/parser.js.html b/vendors/DateJS/reports/lcov-report/core/parser.js.html new file mode 100644 index 0000000..782c71e --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/parser.js.html @@ -0,0 +1,940 @@ + + + + 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);
+	};
+}());
+ 
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/parsing_grammar.js.html b/vendors/DateJS/reports/lcov-report/core/parsing_grammar.js.html new file mode 100644 index 0000000..06b2adc --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/parsing_grammar.js.html @@ -0,0 +1,1249 @@ + + + + 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);
+	};
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/parsing_operators.js.html b/vendors/DateJS/reports/lcov-report/core/parsing_operators.js.html new file mode 100644 index 0000000..afd5493 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/parsing_operators.js.html @@ -0,0 +1,1693 @@ + + + + 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]]);
+	}
+	
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/parsing_translator.js.html b/vendors/DateJS/reports/lcov-report/core/parsing_translator.js.html new file mode 100644 index 0000000..b70af7a --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/parsing_translator.js.html @@ -0,0 +1,1405 @@ + + + + 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;
+		}
+	};
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/sugarpak.js.html b/vendors/DateJS/reports/lcov-report/core/sugarpak.js.html new file mode 100644 index 0000000..a6aea6e --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/sugarpak.js.html @@ -0,0 +1,1801 @@ + + + + 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);
+	}
+}());
+ 
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/time_period.js.html b/vendors/DateJS/reports/lcov-report/core/time_period.js.html new file mode 100644 index 0000000..99a44ad --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/time_period.js.html @@ -0,0 +1,622 @@ + + + + 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;
+	}
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/core/time_span.js.html b/vendors/DateJS/reports/lcov-report/core/time_span.js.html new file mode 100644 index 0000000..314fa46 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/core/time_span.js.html @@ -0,0 +1,847 @@ + + + + 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;
+	}
+}());
+ +
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/index.html b/vendors/DateJS/reports/lcov-report/index.html new file mode 100644 index 0000000..cab2fd9 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/index.html @@ -0,0 +1,350 @@ + + + + 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      +

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
core/82.29%(1385 / 1683)70.61%(793 / 1123)83.48%(288 / 345)82.5%(1377 / 1669)
+
+
+ + + + + + + + diff --git a/vendors/DateJS/reports/lcov-report/prettify.css b/vendors/DateJS/reports/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/prettify.css @@ -0,0 +1 @@ +.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} diff --git a/vendors/DateJS/reports/lcov-report/prettify.js b/vendors/DateJS/reports/lcov-report/prettify.js new file mode 100644 index 0000000..ef51e03 --- /dev/null +++ b/vendors/DateJS/reports/lcov-report/prettify.js @@ -0,0 +1 @@ +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"]); diff --git a/vendors/DateJS/reports/lcov.info b/vendors/DateJS/reports/lcov.info new file mode 100644 index 0000000..070fca3 --- /dev/null +++ b/vendors/DateJS/reports/lcov.info @@ -0,0 +1,3590 @@ +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 diff --git a/vendors/DateJS/src/core/core-prototypes.js b/vendors/DateJS/src/core/core-prototypes.js new file mode 100644 index 0000000..c5d5cc2 --- /dev/null +++ b/vendors/DateJS/src/core/core-prototypes.js @@ -0,0 +1,769 @@ +(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 (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 (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(); + }; + +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/core.js b/vendors/DateJS/src/core/core.js new file mode 100644 index 0000000..881a85a --- /dev/null +++ b/vendors/DateJS/src/core/core.js @@ -0,0 +1,343 @@ +(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); + }; + +}()); diff --git a/vendors/DateJS/src/core/extras.js b/vendors/DateJS/src/core/extras.js new file mode 100644 index 0000000..c061c25 --- /dev/null +++ b/vendors/DateJS/src/core/extras.js @@ -0,0 +1,314 @@ +(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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/format_parser.js b/vendors/DateJS/src/core/format_parser.js new file mode 100644 index 0000000..48f5f84 --- /dev/null +++ b/vendors/DateJS/src/core/format_parser.js @@ -0,0 +1,381 @@ +(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(); +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/i18n.js b/vendors/DateJS/src/core/i18n.js new file mode 100644 index 0000000..8a7efbf --- /dev/null +++ b/vendors/DateJS/src/core/i18n.js @@ -0,0 +1,416 @@ +(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 +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/parser.js b/vendors/DateJS/src/core/parser.js new file mode 100644 index 0000000..358f2a7 --- /dev/null +++ b/vendors/DateJS/src/core/parser.js @@ -0,0 +1,206 @@ +(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); + }; +}()); diff --git a/vendors/DateJS/src/core/parsing_grammar.js b/vendors/DateJS/src/core/parsing_grammar.js new file mode 100644 index 0000000..03a6f0a --- /dev/null +++ b/vendors/DateJS/src/core/parsing_grammar.js @@ -0,0 +1,310 @@ +(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.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) { + 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); + }; +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/parsing_operators.js b/vendors/DateJS/src/core/parsing_operators.js new file mode 100644 index 0000000..fe4d367 --- /dev/null +++ b/vendors/DateJS/src/core/parsing_operators.js @@ -0,0 +1,458 @@ +(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]]); + } + +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/parsing_translator.js b/vendors/DateJS/src/core/parsing_translator.js new file mode 100644 index 0000000..a15418f --- /dev/null +++ b/vendors/DateJS/src/core/parsing_translator.js @@ -0,0 +1,362 @@ +(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; + } + }; +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/sugarpak.js b/vendors/DateJS/src/core/sugarpak.js new file mode 100644 index 0000000..ef28512 --- /dev/null +++ b/vendors/DateJS/src/core/sugarpak.js @@ -0,0 +1,493 @@ +/************************************************************* + * 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); + } +}()); diff --git a/vendors/DateJS/src/core/time_period.js b/vendors/DateJS/src/core/time_period.js new file mode 100644 index 0000000..9f86ef9 --- /dev/null +++ b/vendors/DateJS/src/core/time_period.js @@ -0,0 +1,101 @@ +(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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/core/time_span.js b/vendors/DateJS/src/core/time_span.js new file mode 100644 index 0000000..c71d804 --- /dev/null +++ b/vendors/DateJS/src/core/time_span.js @@ -0,0 +1,176 @@ +(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; + } +}()); \ No newline at end of file diff --git a/vendors/DateJS/src/i18n-template.js b/vendors/DateJS/src/i18n-template.js new file mode 100644 index 0000000..c620ec1 --- /dev/null +++ b/vendors/DateJS/src/i18n-template.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/af-ZA.js b/vendors/DateJS/src/i18n/af-ZA.js new file mode 100644 index 0000000..49d7b25 --- /dev/null +++ b/vendors/DateJS/src/i18n/af-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-AE.js b/vendors/DateJS/src/i18n/ar-AE.js new file mode 100644 index 0000000..23c772c --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-AE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-BH.js b/vendors/DateJS/src/i18n/ar-BH.js new file mode 100644 index 0000000..2a9e4ab --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-BH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-DZ.js b/vendors/DateJS/src/i18n/ar-DZ.js new file mode 100644 index 0000000..b5fefab --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-DZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-EG.js b/vendors/DateJS/src/i18n/ar-EG.js new file mode 100644 index 0000000..bb06d79 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-EG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-IQ.js b/vendors/DateJS/src/i18n/ar-IQ.js new file mode 100644 index 0000000..fbd2e41 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-IQ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-JO.js b/vendors/DateJS/src/i18n/ar-JO.js new file mode 100644 index 0000000..e5b621c --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-JO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-KW.js b/vendors/DateJS/src/i18n/ar-KW.js new file mode 100644 index 0000000..630c44c --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-KW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-LB.js b/vendors/DateJS/src/i18n/ar-LB.js new file mode 100644 index 0000000..ae11658 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-LB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-LY.js b/vendors/DateJS/src/i18n/ar-LY.js new file mode 100644 index 0000000..3964bad --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-LY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-MA.js b/vendors/DateJS/src/i18n/ar-MA.js new file mode 100644 index 0000000..9e22c05 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-MA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-OM.js b/vendors/DateJS/src/i18n/ar-OM.js new file mode 100644 index 0000000..6d76101 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-OM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-QA.js b/vendors/DateJS/src/i18n/ar-QA.js new file mode 100644 index 0000000..89056c5 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-QA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-SA.js b/vendors/DateJS/src/i18n/ar-SA.js new file mode 100644 index 0000000..379b14f --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-SA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-SY.js b/vendors/DateJS/src/i18n/ar-SY.js new file mode 100644 index 0000000..ff34f95 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-SY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-TN.js b/vendors/DateJS/src/i18n/ar-TN.js new file mode 100644 index 0000000..1fff2f0 --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-TN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ar-YE.js b/vendors/DateJS/src/i18n/ar-YE.js new file mode 100644 index 0000000..4607a0f --- /dev/null +++ b/vendors/DateJS/src/i18n/ar-YE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/az-Cyrl-AZ.js b/vendors/DateJS/src/i18n/az-Cyrl-AZ.js new file mode 100644 index 0000000..19a2673 --- /dev/null +++ b/vendors/DateJS/src/i18n/az-Cyrl-AZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/az-Latn-AZ.js b/vendors/DateJS/src/i18n/az-Latn-AZ.js new file mode 100644 index 0000000..7014595 --- /dev/null +++ b/vendors/DateJS/src/i18n/az-Latn-AZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/be-BY.js b/vendors/DateJS/src/i18n/be-BY.js new file mode 100644 index 0000000..072226d --- /dev/null +++ b/vendors/DateJS/src/i18n/be-BY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/bg-BG.js b/vendors/DateJS/src/i18n/bg-BG.js new file mode 100644 index 0000000..1945de9 --- /dev/null +++ b/vendors/DateJS/src/i18n/bg-BG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/bs-Latn-BA.js b/vendors/DateJS/src/i18n/bs-Latn-BA.js new file mode 100644 index 0000000..7b93ecd --- /dev/null +++ b/vendors/DateJS/src/i18n/bs-Latn-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ca-ES.js b/vendors/DateJS/src/i18n/ca-ES.js new file mode 100644 index 0000000..ef13faa --- /dev/null +++ b/vendors/DateJS/src/i18n/ca-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/cs-CZ.js b/vendors/DateJS/src/i18n/cs-CZ.js new file mode 100644 index 0000000..b8a3265 --- /dev/null +++ b/vendors/DateJS/src/i18n/cs-CZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/cy-GB.js b/vendors/DateJS/src/i18n/cy-GB.js new file mode 100644 index 0000000..b8cfb75 --- /dev/null +++ b/vendors/DateJS/src/i18n/cy-GB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/da-DK.js b/vendors/DateJS/src/i18n/da-DK.js new file mode 100644 index 0000000..6216118 --- /dev/null +++ b/vendors/DateJS/src/i18n/da-DK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/de-AT.js b/vendors/DateJS/src/i18n/de-AT.js new file mode 100644 index 0000000..9bb0c5f --- /dev/null +++ b/vendors/DateJS/src/i18n/de-AT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/de-CH.js b/vendors/DateJS/src/i18n/de-CH.js new file mode 100644 index 0000000..92486d1 --- /dev/null +++ b/vendors/DateJS/src/i18n/de-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/de-DE.js b/vendors/DateJS/src/i18n/de-DE.js new file mode 100644 index 0000000..d084715 --- /dev/null +++ b/vendors/DateJS/src/i18n/de-DE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/de-LI.js b/vendors/DateJS/src/i18n/de-LI.js new file mode 100644 index 0000000..a2c9afd --- /dev/null +++ b/vendors/DateJS/src/i18n/de-LI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/de-LU.js b/vendors/DateJS/src/i18n/de-LU.js new file mode 100644 index 0000000..83fe014 --- /dev/null +++ b/vendors/DateJS/src/i18n/de-LU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/dv-MV.js b/vendors/DateJS/src/i18n/dv-MV.js new file mode 100644 index 0000000..de2abfe --- /dev/null +++ b/vendors/DateJS/src/i18n/dv-MV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/el-GR.js b/vendors/DateJS/src/i18n/el-GR.js new file mode 100644 index 0000000..189174c --- /dev/null +++ b/vendors/DateJS/src/i18n/el-GR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-029.js b/vendors/DateJS/src/i18n/en-029.js new file mode 100644 index 0000000..a38d273 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-029.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-AU.js b/vendors/DateJS/src/i18n/en-AU.js new file mode 100644 index 0000000..9a3c38b --- /dev/null +++ b/vendors/DateJS/src/i18n/en-AU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-BZ.js b/vendors/DateJS/src/i18n/en-BZ.js new file mode 100644 index 0000000..488e436 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-BZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-CA.js b/vendors/DateJS/src/i18n/en-CA.js new file mode 100644 index 0000000..952ae45 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-CA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-GB.js b/vendors/DateJS/src/i18n/en-GB.js new file mode 100644 index 0000000..186da92 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-GB.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-IE.js b/vendors/DateJS/src/i18n/en-IE.js new file mode 100644 index 0000000..3fdb220 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-IE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-JM.js b/vendors/DateJS/src/i18n/en-JM.js new file mode 100644 index 0000000..5ea1c73 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-JM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-NZ.js b/vendors/DateJS/src/i18n/en-NZ.js new file mode 100644 index 0000000..5dc1d74 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-NZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-PH.js b/vendors/DateJS/src/i18n/en-PH.js new file mode 100644 index 0000000..6877b63 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-PH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-TT.js b/vendors/DateJS/src/i18n/en-TT.js new file mode 100644 index 0000000..c4ab826 --- /dev/null +++ b/vendors/DateJS/src/i18n/en-TT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-ZA.js b/vendors/DateJS/src/i18n/en-ZA.js new file mode 100644 index 0000000..1b928cc --- /dev/null +++ b/vendors/DateJS/src/i18n/en-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/en-ZW.js b/vendors/DateJS/src/i18n/en-ZW.js new file mode 100644 index 0000000..c6d320d --- /dev/null +++ b/vendors/DateJS/src/i18n/en-ZW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-AR.js b/vendors/DateJS/src/i18n/es-AR.js new file mode 100644 index 0000000..b252d68 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-AR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-BO.js b/vendors/DateJS/src/i18n/es-BO.js new file mode 100644 index 0000000..754b63b --- /dev/null +++ b/vendors/DateJS/src/i18n/es-BO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-CL.js b/vendors/DateJS/src/i18n/es-CL.js new file mode 100644 index 0000000..7cf7de8 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-CL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-CO.js b/vendors/DateJS/src/i18n/es-CO.js new file mode 100644 index 0000000..d5b6e42 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-CO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-CR.js b/vendors/DateJS/src/i18n/es-CR.js new file mode 100644 index 0000000..4b2c07f --- /dev/null +++ b/vendors/DateJS/src/i18n/es-CR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-DO.js b/vendors/DateJS/src/i18n/es-DO.js new file mode 100644 index 0000000..a49f07b --- /dev/null +++ b/vendors/DateJS/src/i18n/es-DO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-EC.js b/vendors/DateJS/src/i18n/es-EC.js new file mode 100644 index 0000000..3954575 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-EC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-ES.js b/vendors/DateJS/src/i18n/es-ES.js new file mode 100644 index 0000000..cfcf8c7 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-GT.js b/vendors/DateJS/src/i18n/es-GT.js new file mode 100644 index 0000000..8a80314 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-GT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-HN.js b/vendors/DateJS/src/i18n/es-HN.js new file mode 100644 index 0000000..eec6809 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-HN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-MX.js b/vendors/DateJS/src/i18n/es-MX.js new file mode 100644 index 0000000..706a721 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-MX.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-NI.js b/vendors/DateJS/src/i18n/es-NI.js new file mode 100644 index 0000000..5387f8e --- /dev/null +++ b/vendors/DateJS/src/i18n/es-NI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-PA.js b/vendors/DateJS/src/i18n/es-PA.js new file mode 100644 index 0000000..c290b9e --- /dev/null +++ b/vendors/DateJS/src/i18n/es-PA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-PE.js b/vendors/DateJS/src/i18n/es-PE.js new file mode 100644 index 0000000..2494ed0 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-PE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-PR.js b/vendors/DateJS/src/i18n/es-PR.js new file mode 100644 index 0000000..b00dea4 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-PR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-PY.js b/vendors/DateJS/src/i18n/es-PY.js new file mode 100644 index 0000000..001b407 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-PY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-SV.js b/vendors/DateJS/src/i18n/es-SV.js new file mode 100644 index 0000000..2aafe35 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-SV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-UY.js b/vendors/DateJS/src/i18n/es-UY.js new file mode 100644 index 0000000..ae7da2e --- /dev/null +++ b/vendors/DateJS/src/i18n/es-UY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/es-VE.js b/vendors/DateJS/src/i18n/es-VE.js new file mode 100644 index 0000000..f8fb647 --- /dev/null +++ b/vendors/DateJS/src/i18n/es-VE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/et-EE.js b/vendors/DateJS/src/i18n/et-EE.js new file mode 100644 index 0000000..fe130f9 --- /dev/null +++ b/vendors/DateJS/src/i18n/et-EE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/eu-ES.js b/vendors/DateJS/src/i18n/eu-ES.js new file mode 100644 index 0000000..d3cde8a --- /dev/null +++ b/vendors/DateJS/src/i18n/eu-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fa-IR.js b/vendors/DateJS/src/i18n/fa-IR.js new file mode 100644 index 0000000..8198538 --- /dev/null +++ b/vendors/DateJS/src/i18n/fa-IR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fi-FI.js b/vendors/DateJS/src/i18n/fi-FI.js new file mode 100644 index 0000000..12f9a44 --- /dev/null +++ b/vendors/DateJS/src/i18n/fi-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fo-FO.js b/vendors/DateJS/src/i18n/fo-FO.js new file mode 100644 index 0000000..802a20b --- /dev/null +++ b/vendors/DateJS/src/i18n/fo-FO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-BE.js b/vendors/DateJS/src/i18n/fr-BE.js new file mode 100644 index 0000000..8ff63bf --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-BE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-CA.js b/vendors/DateJS/src/i18n/fr-CA.js new file mode 100644 index 0000000..27ce919 --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-CA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-CH.js b/vendors/DateJS/src/i18n/fr-CH.js new file mode 100644 index 0000000..be79585 --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-FR.js b/vendors/DateJS/src/i18n/fr-FR.js new file mode 100644 index 0000000..12366a0 --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-FR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-LU.js b/vendors/DateJS/src/i18n/fr-LU.js new file mode 100644 index 0000000..0ca498d --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-LU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/fr-MC.js b/vendors/DateJS/src/i18n/fr-MC.js new file mode 100644 index 0000000..cd423ce --- /dev/null +++ b/vendors/DateJS/src/i18n/fr-MC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/gl-ES.js b/vendors/DateJS/src/i18n/gl-ES.js new file mode 100644 index 0000000..2873c9e --- /dev/null +++ b/vendors/DateJS/src/i18n/gl-ES.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/gu-IN.js b/vendors/DateJS/src/i18n/gu-IN.js new file mode 100644 index 0000000..8e4e8d5 --- /dev/null +++ b/vendors/DateJS/src/i18n/gu-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/he-IL.js b/vendors/DateJS/src/i18n/he-IL.js new file mode 100644 index 0000000..77fecc0 --- /dev/null +++ b/vendors/DateJS/src/i18n/he-IL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/hi-IN.js b/vendors/DateJS/src/i18n/hi-IN.js new file mode 100644 index 0000000..06185b1 --- /dev/null +++ b/vendors/DateJS/src/i18n/hi-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/hr-BA.js b/vendors/DateJS/src/i18n/hr-BA.js new file mode 100644 index 0000000..9fe88fc --- /dev/null +++ b/vendors/DateJS/src/i18n/hr-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/hr-HR.js b/vendors/DateJS/src/i18n/hr-HR.js new file mode 100644 index 0000000..0f9d816 --- /dev/null +++ b/vendors/DateJS/src/i18n/hr-HR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/hu-HU.js b/vendors/DateJS/src/i18n/hu-HU.js new file mode 100644 index 0000000..265edb6 --- /dev/null +++ b/vendors/DateJS/src/i18n/hu-HU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/hy-AM.js b/vendors/DateJS/src/i18n/hy-AM.js new file mode 100644 index 0000000..42ca6dc --- /dev/null +++ b/vendors/DateJS/src/i18n/hy-AM.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/id-ID.js b/vendors/DateJS/src/i18n/id-ID.js new file mode 100644 index 0000000..583d115 --- /dev/null +++ b/vendors/DateJS/src/i18n/id-ID.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/is-IS.js b/vendors/DateJS/src/i18n/is-IS.js new file mode 100644 index 0000000..350e3b3 --- /dev/null +++ b/vendors/DateJS/src/i18n/is-IS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/it-CH.js b/vendors/DateJS/src/i18n/it-CH.js new file mode 100644 index 0000000..e762838 --- /dev/null +++ b/vendors/DateJS/src/i18n/it-CH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/it-IT.js b/vendors/DateJS/src/i18n/it-IT.js new file mode 100644 index 0000000..82267c6 --- /dev/null +++ b/vendors/DateJS/src/i18n/it-IT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ja-JP.js b/vendors/DateJS/src/i18n/ja-JP.js new file mode 100644 index 0000000..1576ffc --- /dev/null +++ b/vendors/DateJS/src/i18n/ja-JP.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ka-GE.js b/vendors/DateJS/src/i18n/ka-GE.js new file mode 100644 index 0000000..2e1e618 --- /dev/null +++ b/vendors/DateJS/src/i18n/ka-GE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/kk-KZ.js b/vendors/DateJS/src/i18n/kk-KZ.js new file mode 100644 index 0000000..877e098 --- /dev/null +++ b/vendors/DateJS/src/i18n/kk-KZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/kn-IN.js b/vendors/DateJS/src/i18n/kn-IN.js new file mode 100644 index 0000000..7d60e0e --- /dev/null +++ b/vendors/DateJS/src/i18n/kn-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ko-KR.js b/vendors/DateJS/src/i18n/ko-KR.js new file mode 100644 index 0000000..c34ba8d --- /dev/null +++ b/vendors/DateJS/src/i18n/ko-KR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/kok-IN.js b/vendors/DateJS/src/i18n/kok-IN.js new file mode 100644 index 0000000..bdc2b9d --- /dev/null +++ b/vendors/DateJS/src/i18n/kok-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ky-KG.js b/vendors/DateJS/src/i18n/ky-KG.js new file mode 100644 index 0000000..91c7f45 --- /dev/null +++ b/vendors/DateJS/src/i18n/ky-KG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/lt-LT.js b/vendors/DateJS/src/i18n/lt-LT.js new file mode 100644 index 0000000..9b33011 --- /dev/null +++ b/vendors/DateJS/src/i18n/lt-LT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/lv-LV.js b/vendors/DateJS/src/i18n/lv-LV.js new file mode 100644 index 0000000..4e945d1 --- /dev/null +++ b/vendors/DateJS/src/i18n/lv-LV.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/mi-NZ.js b/vendors/DateJS/src/i18n/mi-NZ.js new file mode 100644 index 0000000..935ed3b --- /dev/null +++ b/vendors/DateJS/src/i18n/mi-NZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/mk-MK.js b/vendors/DateJS/src/i18n/mk-MK.js new file mode 100644 index 0000000..96b704d --- /dev/null +++ b/vendors/DateJS/src/i18n/mk-MK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/mn-MN.js b/vendors/DateJS/src/i18n/mn-MN.js new file mode 100644 index 0000000..f8f748a --- /dev/null +++ b/vendors/DateJS/src/i18n/mn-MN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/mr-IN.js b/vendors/DateJS/src/i18n/mr-IN.js new file mode 100644 index 0000000..7be3036 --- /dev/null +++ b/vendors/DateJS/src/i18n/mr-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ms-BN.js b/vendors/DateJS/src/i18n/ms-BN.js new file mode 100644 index 0000000..39a7b32 --- /dev/null +++ b/vendors/DateJS/src/i18n/ms-BN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ms-MY.js b/vendors/DateJS/src/i18n/ms-MY.js new file mode 100644 index 0000000..024b81b --- /dev/null +++ b/vendors/DateJS/src/i18n/ms-MY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/mt-MT.js b/vendors/DateJS/src/i18n/mt-MT.js new file mode 100644 index 0000000..ede62ee --- /dev/null +++ b/vendors/DateJS/src/i18n/mt-MT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/nb-NO.js b/vendors/DateJS/src/i18n/nb-NO.js new file mode 100644 index 0000000..90b6182 --- /dev/null +++ b/vendors/DateJS/src/i18n/nb-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/nl-BE.js b/vendors/DateJS/src/i18n/nl-BE.js new file mode 100644 index 0000000..ff90c34 --- /dev/null +++ b/vendors/DateJS/src/i18n/nl-BE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/nl-NL.js b/vendors/DateJS/src/i18n/nl-NL.js new file mode 100644 index 0000000..b3b5d9a --- /dev/null +++ b/vendors/DateJS/src/i18n/nl-NL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/nn-NO.js b/vendors/DateJS/src/i18n/nn-NO.js new file mode 100644 index 0000000..8b75035 --- /dev/null +++ b/vendors/DateJS/src/i18n/nn-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ns-ZA.js b/vendors/DateJS/src/i18n/ns-ZA.js new file mode 100644 index 0000000..520ba05 --- /dev/null +++ b/vendors/DateJS/src/i18n/ns-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/pa-IN.js b/vendors/DateJS/src/i18n/pa-IN.js new file mode 100644 index 0000000..bbf4450 --- /dev/null +++ b/vendors/DateJS/src/i18n/pa-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/pl-PL.js b/vendors/DateJS/src/i18n/pl-PL.js new file mode 100644 index 0000000..72b47f3 --- /dev/null +++ b/vendors/DateJS/src/i18n/pl-PL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/pt-BR.js b/vendors/DateJS/src/i18n/pt-BR.js new file mode 100644 index 0000000..23d47be --- /dev/null +++ b/vendors/DateJS/src/i18n/pt-BR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/pt-PT.js b/vendors/DateJS/src/i18n/pt-PT.js new file mode 100644 index 0000000..e4f740f --- /dev/null +++ b/vendors/DateJS/src/i18n/pt-PT.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/quz-BO.js b/vendors/DateJS/src/i18n/quz-BO.js new file mode 100644 index 0000000..059e913 --- /dev/null +++ b/vendors/DateJS/src/i18n/quz-BO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/quz-EC.js b/vendors/DateJS/src/i18n/quz-EC.js new file mode 100644 index 0000000..698fcc2 --- /dev/null +++ b/vendors/DateJS/src/i18n/quz-EC.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/quz-PE.js b/vendors/DateJS/src/i18n/quz-PE.js new file mode 100644 index 0000000..5d3c93b --- /dev/null +++ b/vendors/DateJS/src/i18n/quz-PE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ro-RO.js b/vendors/DateJS/src/i18n/ro-RO.js new file mode 100644 index 0000000..7352b15 --- /dev/null +++ b/vendors/DateJS/src/i18n/ro-RO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ru-RU.js b/vendors/DateJS/src/i18n/ru-RU.js new file mode 100644 index 0000000..b28ffdb --- /dev/null +++ b/vendors/DateJS/src/i18n/ru-RU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sa-IN.js b/vendors/DateJS/src/i18n/sa-IN.js new file mode 100644 index 0000000..eba2aa1 --- /dev/null +++ b/vendors/DateJS/src/i18n/sa-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/se-FI.js b/vendors/DateJS/src/i18n/se-FI.js new file mode 100644 index 0000000..ab7bcd6 --- /dev/null +++ b/vendors/DateJS/src/i18n/se-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/se-NO.js b/vendors/DateJS/src/i18n/se-NO.js new file mode 100644 index 0000000..005cb99 --- /dev/null +++ b/vendors/DateJS/src/i18n/se-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/se-SE.js b/vendors/DateJS/src/i18n/se-SE.js new file mode 100644 index 0000000..88e51b3 --- /dev/null +++ b/vendors/DateJS/src/i18n/se-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sk-SK.js b/vendors/DateJS/src/i18n/sk-SK.js new file mode 100644 index 0000000..310f8ad --- /dev/null +++ b/vendors/DateJS/src/i18n/sk-SK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sl-SI.js b/vendors/DateJS/src/i18n/sl-SI.js new file mode 100644 index 0000000..8c388fb --- /dev/null +++ b/vendors/DateJS/src/i18n/sl-SI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sma-NO.js b/vendors/DateJS/src/i18n/sma-NO.js new file mode 100644 index 0000000..31f872a --- /dev/null +++ b/vendors/DateJS/src/i18n/sma-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sma-SE.js b/vendors/DateJS/src/i18n/sma-SE.js new file mode 100644 index 0000000..67f8091 --- /dev/null +++ b/vendors/DateJS/src/i18n/sma-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/smj-NO.js b/vendors/DateJS/src/i18n/smj-NO.js new file mode 100644 index 0000000..6d25dc0 --- /dev/null +++ b/vendors/DateJS/src/i18n/smj-NO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/smj-SE.js b/vendors/DateJS/src/i18n/smj-SE.js new file mode 100644 index 0000000..a11f322 --- /dev/null +++ b/vendors/DateJS/src/i18n/smj-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/smn-FI.js b/vendors/DateJS/src/i18n/smn-FI.js new file mode 100644 index 0000000..2fde1e5 --- /dev/null +++ b/vendors/DateJS/src/i18n/smn-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sms-FI.js b/vendors/DateJS/src/i18n/sms-FI.js new file mode 100644 index 0000000..ee5b034 --- /dev/null +++ b/vendors/DateJS/src/i18n/sms-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sq-AL.js b/vendors/DateJS/src/i18n/sq-AL.js new file mode 100644 index 0000000..474a331 --- /dev/null +++ b/vendors/DateJS/src/i18n/sq-AL.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sr-Cyrl-BA.js b/vendors/DateJS/src/i18n/sr-Cyrl-BA.js new file mode 100644 index 0000000..14eb2a7 --- /dev/null +++ b/vendors/DateJS/src/i18n/sr-Cyrl-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sr-Cyrl-CS.js b/vendors/DateJS/src/i18n/sr-Cyrl-CS.js new file mode 100644 index 0000000..383c58b --- /dev/null +++ b/vendors/DateJS/src/i18n/sr-Cyrl-CS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sr-Latn-BA.js b/vendors/DateJS/src/i18n/sr-Latn-BA.js new file mode 100644 index 0000000..afe178e --- /dev/null +++ b/vendors/DateJS/src/i18n/sr-Latn-BA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sr-Latn-CS.js b/vendors/DateJS/src/i18n/sr-Latn-CS.js new file mode 100644 index 0000000..03ff833 --- /dev/null +++ b/vendors/DateJS/src/i18n/sr-Latn-CS.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sv-FI.js b/vendors/DateJS/src/i18n/sv-FI.js new file mode 100644 index 0000000..c308075 --- /dev/null +++ b/vendors/DateJS/src/i18n/sv-FI.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sv-SE.js b/vendors/DateJS/src/i18n/sv-SE.js new file mode 100644 index 0000000..f51ee50 --- /dev/null +++ b/vendors/DateJS/src/i18n/sv-SE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/sw-KE.js b/vendors/DateJS/src/i18n/sw-KE.js new file mode 100644 index 0000000..65fcb28 --- /dev/null +++ b/vendors/DateJS/src/i18n/sw-KE.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/syr-SY.js b/vendors/DateJS/src/i18n/syr-SY.js new file mode 100644 index 0000000..27c4232 --- /dev/null +++ b/vendors/DateJS/src/i18n/syr-SY.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ta-IN.js b/vendors/DateJS/src/i18n/ta-IN.js new file mode 100644 index 0000000..4dd916c --- /dev/null +++ b/vendors/DateJS/src/i18n/ta-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/te-IN.js b/vendors/DateJS/src/i18n/te-IN.js new file mode 100644 index 0000000..00ad7d3 --- /dev/null +++ b/vendors/DateJS/src/i18n/te-IN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/th-TH.js b/vendors/DateJS/src/i18n/th-TH.js new file mode 100644 index 0000000..c783f3f --- /dev/null +++ b/vendors/DateJS/src/i18n/th-TH.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/tn-ZA.js b/vendors/DateJS/src/i18n/tn-ZA.js new file mode 100644 index 0000000..06112fd --- /dev/null +++ b/vendors/DateJS/src/i18n/tn-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/tr-TR.js b/vendors/DateJS/src/i18n/tr-TR.js new file mode 100644 index 0000000..d5c4223 --- /dev/null +++ b/vendors/DateJS/src/i18n/tr-TR.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/tt-RU.js b/vendors/DateJS/src/i18n/tt-RU.js new file mode 100644 index 0000000..5e9f4c2 --- /dev/null +++ b/vendors/DateJS/src/i18n/tt-RU.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/uk-UA.js b/vendors/DateJS/src/i18n/uk-UA.js new file mode 100644 index 0000000..adb15c1 --- /dev/null +++ b/vendors/DateJS/src/i18n/uk-UA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/ur-PK.js b/vendors/DateJS/src/i18n/ur-PK.js new file mode 100644 index 0000000..1cfdc5c --- /dev/null +++ b/vendors/DateJS/src/i18n/ur-PK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/uz-Cyrl-UZ.js b/vendors/DateJS/src/i18n/uz-Cyrl-UZ.js new file mode 100644 index 0000000..1a1e7a0 --- /dev/null +++ b/vendors/DateJS/src/i18n/uz-Cyrl-UZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/uz-Latn-UZ.js b/vendors/DateJS/src/i18n/uz-Latn-UZ.js new file mode 100644 index 0000000..330b7da --- /dev/null +++ b/vendors/DateJS/src/i18n/uz-Latn-UZ.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/vi-VN.js b/vendors/DateJS/src/i18n/vi-VN.js new file mode 100644 index 0000000..c63a5f9 --- /dev/null +++ b/vendors/DateJS/src/i18n/vi-VN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/xh-ZA.js b/vendors/DateJS/src/i18n/xh-ZA.js new file mode 100644 index 0000000..46fd37a --- /dev/null +++ b/vendors/DateJS/src/i18n/xh-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zh-CN.js b/vendors/DateJS/src/i18n/zh-CN.js new file mode 100644 index 0000000..54a1f10 --- /dev/null +++ b/vendors/DateJS/src/i18n/zh-CN.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zh-HK.js b/vendors/DateJS/src/i18n/zh-HK.js new file mode 100644 index 0000000..1ec1482 --- /dev/null +++ b/vendors/DateJS/src/i18n/zh-HK.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zh-MO.js b/vendors/DateJS/src/i18n/zh-MO.js new file mode 100644 index 0000000..6606109 --- /dev/null +++ b/vendors/DateJS/src/i18n/zh-MO.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zh-SG.js b/vendors/DateJS/src/i18n/zh-SG.js new file mode 100644 index 0000000..e674dfa --- /dev/null +++ b/vendors/DateJS/src/i18n/zh-SG.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zh-TW.js b/vendors/DateJS/src/i18n/zh-TW.js new file mode 100644 index 0000000..29f7811 --- /dev/null +++ b/vendors/DateJS/src/i18n/zh-TW.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/DateJS/src/i18n/zu-ZA.js b/vendors/DateJS/src/i18n/zu-ZA.js new file mode 100644 index 0000000..25b0f8e --- /dev/null +++ b/vendors/DateJS/src/i18n/zu-ZA.js @@ -0,0 +1,178 @@ +/* + * 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"; diff --git a/vendors/Flot/.bower.json b/vendors/Flot/.bower.json index bab985a..cf0cf53 100644 --- a/vendors/Flot/.bower.json +++ b/vendors/Flot/.bower.json @@ -13,6 +13,6 @@ "commit": "453b017cc5acfd75e252b93e8635f57f4196d45d" }, "_source": "https://github.com/flot/flot.git", - "_target": "^0.8.3", + "_target": ">=0.8.0", "_originalSource": "flot" } \ No newline at end of file diff --git a/vendors/flot-spline/.bower.json b/vendors/flot-spline/.bower.json new file mode 100644 index 0000000..ab3aed6 --- /dev/null +++ b/vendors/flot-spline/.bower.json @@ -0,0 +1,33 @@ +{ + "name": "flot-spline", + "version": "0.8.2", + "homepage": "https://github.com/JohnPozy/flot-spline", + "authors": [ + "Alex Bardas < alex.bardas@gmail.com >" + ], + "description": "Flot plugin that provides spline interpolation for line graphs", + "keywords": [ + "jquery", + "flot", + "spline" + ], + "license": "SEE LICENSE IN LICENSE", + "main": "js/jquery.flot.spline.js", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "_release": "0.8.2", + "_resolution": { + "type": "version", + "tag": "0.8.2", + "commit": "2ddbb1782735cc269dd57a7c7c69381ce8221159" + }, + "_source": "https://github.com/JohnPozy/flot-spline.git", + "_target": "^0.8.2", + "_originalSource": "flot-spline", + "_direct": true +} \ No newline at end of file diff --git a/vendors/flot-spline/LICENSE b/vendors/flot-spline/LICENSE new file mode 100644 index 0000000..f6b1375 --- /dev/null +++ b/vendors/flot-spline/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2007-2014 IOLA and Ole Laursen + +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. \ No newline at end of file diff --git a/vendors/flot-spline/bower.json b/vendors/flot-spline/bower.json new file mode 100644 index 0000000..3cc5d97 --- /dev/null +++ b/vendors/flot-spline/bower.json @@ -0,0 +1,23 @@ +{ + "name": "flot-spline", + "version": "0.0.1", + "homepage": "https://github.com/JohnPozy/flot-spline", + "authors": [ + "Alex Bardas < alex.bardas@gmail.com >" + ], + "description": "Flot plugin that provides spline interpolation for line graphs", + "keywords": [ + "jquery", + "flot", + "spline" + ], + "license": "SEE LICENSE IN LICENSE", + "main": "js/jquery.flot.spline.js", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/vendors/flot-spline/js/jquery.flot.spline.js b/vendors/flot-spline/js/jquery.flot.spline.js new file mode 100644 index 0000000..71f1c41 --- /dev/null +++ b/vendors/flot-spline/js/jquery.flot.spline.js @@ -0,0 +1,212 @@ +/** + * Flot plugin that provides spline interpolation for line graphs + * author: Alex Bardas < alex.bardas@gmail.com > + * modified by: Avi Kohn https://github.com/AMKohn + * based on the spline interpolation described at: + * http://scaledinnovation.com/analytics/splines/aboutSplines.html + * + * Example usage: (add in plot options series object) + * for linespline: + * series: { + * ... + * lines: { + * show: false + * }, + * splines: { + * show: true, + * tension: x, (float between 0 and 1, defaults to 0.5), + * lineWidth: y (number, defaults to 2), + * fill: z (float between 0 .. 1 or false, as in flot documentation) + * }, + * ... + * } + * areaspline: + * series: { + * ... + * lines: { + * show: true, + * lineWidth: 0, (line drawing will not execute) + * fill: x, (float between 0 .. 1, as in flot documentation) + * ... + * }, + * splines: { + * show: true, + * tension: 0.5 (float between 0 and 1) + * }, + * ... + * } + * + */ + +(function($) { + 'use strict' + + /** + * @param {Number} x0, y0, x1, y1: coordinates of the end (knot) points of the segment + * @param {Number} x2, y2: the next knot (not connected, but needed to calculate p2) + * @param {Number} tension: control how far the control points spread + * @return {Array}: p1 -> control point, from x1 back toward x0 + * p2 -> the next control point, returned to become the next segment's p1 + * + * @api private + */ + function getControlPoints(x0, y0, x1, y1, x2, y2, tension) { + + var pow = Math.pow, + sqrt = Math.sqrt, + d01, d12, fa, fb, p1x, p1y, p2x, p2y; + + // Scaling factors: distances from this knot to the previous and following knots. + d01 = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2)); + d12 = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); + + fa = tension * d01 / (d01 + d12); + fb = tension - fa; + + p1x = x1 + fa * (x0 - x2); + p1y = y1 + fa * (y0 - y2); + + p2x = x1 - fb * (x0 - x2); + p2y = y1 - fb * (y0 - y2); + + return [p1x, p1y, p2x, p2y]; + } + + var line = []; + + function drawLine(points, ctx, height, fill, seriesColor) { + var c = $.color.parse(seriesColor); + + c.a = typeof fill == "number" ? fill : .3; + c.normalize(); + c = c.toString(); + + ctx.beginPath(); + ctx.moveTo(points[0][0], points[0][1]); + + var plength = points.length; + + for (var i = 0; i < plength; i++) { + ctx[points[i][3]].apply(ctx, points[i][2]); + } + + ctx.stroke(); + + ctx.lineWidth = 0; + ctx.lineTo(points[plength - 1][0], height); + ctx.lineTo(points[0][0], height); + + ctx.closePath(); + + if (fill !== false) { + ctx.fillStyle = c; + ctx.fill(); + } + } + + /** + * @param {Object} ctx: canvas context + * @param {String} type: accepted strings: 'bezier' or 'quadratic' (defaults to quadratic) + * @param {Array} points: 2 points for which to draw the interpolation + * @param {Array} cpoints: control points for those segment points + * + * @api private + */ + function queue(ctx, type, points, cpoints) { + if (type === void 0 || (type !== 'bezier' && type !== 'quadratic')) { + type = 'quadratic'; + } + type = type + 'CurveTo'; + + if (line.length == 0) line.push([points[0], points[1], cpoints.concat(points.slice(2)), type]); + else if (type == "quadraticCurveTo" && points.length == 2) { + cpoints = cpoints.slice(0, 2).concat(points); + + line.push([points[0], points[1], cpoints, type]); + } + else line.push([points[2], points[3], cpoints.concat(points.slice(2)), type]); + } + + /** + * @param {Object} plot + * @param {Object} ctx: canvas context + * @param {Object} series + * + * @api private + */ + + function drawSpline(plot, ctx, series) { + // Not interested if spline is not requested + if (series.splines.show !== true) { + return; + } + + var cp = [], + // array of control points + tension = series.splines.tension || 0.5, + idx, x, y, points = series.datapoints.points, + ps = series.datapoints.pointsize, + plotOffset = plot.getPlotOffset(), + len = points.length, + pts = []; + + line = []; + + // Cannot display a linespline/areaspline if there are less than 3 points + if (len / ps < 4) { + $.extend(series.lines, series.splines); + return; + } + + for (idx = 0; idx < len; idx += ps) { + x = points[idx]; + y = points[idx + 1]; + if (x == null || x < series.xaxis.min || x > series.xaxis.max || y < series.yaxis.min || y > series.yaxis.max) { + continue; + } + + pts.push(series.xaxis.p2c(x) + plotOffset.left, series.yaxis.p2c(y) + plotOffset.top); + } + + len = pts.length; + + // Draw an open curve, not connected at the ends + for (idx = 0; idx < len - 2; idx += 2) { + cp = cp.concat(getControlPoints.apply(this, pts.slice(idx, idx + 6).concat([tension]))); + } + + ctx.save(); + ctx.strokeStyle = series.color; + ctx.lineWidth = series.splines.lineWidth; + + queue(ctx, 'quadratic', pts.slice(0, 4), cp.slice(0, 2)); + + for (idx = 2; idx < len - 3; idx += 2) { + queue(ctx, 'bezier', pts.slice(idx, idx + 4), cp.slice(2 * idx - 2, 2 * idx + 2)); + } + + queue(ctx, 'quadratic', pts.slice(len - 2, len), [cp[2 * len - 10], cp[2 * len - 9], pts[len - 4], pts[len - 3]]); + + drawLine(line, ctx, plot.height() + 10, series.splines.fill, series.color); + + ctx.restore(); + } + + $.plot.plugins.push({ + init: function(plot) { + plot.hooks.drawSeries.push(drawSpline); + }, + options: { + series: { + splines: { + show: false, + lineWidth: 2, + tension: 0.5, + fill: false + } + } + }, + name: 'spline', + version: '0.8.2' + }); +})(jQuery); diff --git a/vendors/flot-spline/js/jquery.flot.spline.min.js b/vendors/flot-spline/js/jquery.flot.spline.min.js new file mode 100644 index 0000000..65c8a13 --- /dev/null +++ b/vendors/flot-spline/js/jquery.flot.spline.min.js @@ -0,0 +1 @@ +!function(a){"use strict";function b(a,b,c,d,e,f,g){var j,k,l,m,n,o,p,q,h=Math.pow,i=Math.sqrt;return j=i(h(c-a,2)+h(d-b,2)),k=i(h(e-c,2)+h(f-d,2)),l=g*j/(j+k),m=g-l,n=c+l*(a-e),o=d+l*(b-f),p=c-m*(a-e),q=d-m*(b-f),[n,o,p,q]}function d(b,c,d,e,f){var g=a.color.parse(f);g.a="number"==typeof e?e:.3,g.normalize(),g=g.toString(),c.beginPath(),c.moveTo(b[0][0],b[0][1]);for(var h=b.length,i=0;h>i;i++)c[b[i][3]].apply(c,b[i][2]);c.stroke(),c.lineWidth=0,c.lineTo(b[h-1][0],d),c.lineTo(b[0][0],d),c.closePath(),e!==!1&&(c.fillStyle=g,c.fill())}function e(a,b,d,e){(void 0===b||"bezier"!==b&&"quadratic"!==b)&&(b="quadratic"),b+="CurveTo",0==c.length?c.push([d[0],d[1],e.concat(d.slice(2)),b]):"quadraticCurveTo"==b&&2==d.length?(e=e.slice(0,2).concat(d),c.push([d[0],d[1],e,b])):c.push([d[2],d[3],e.concat(d.slice(2)),b])}function f(f,g,h){if(h.splines.show===!0){var k,l,m,i=[],j=h.splines.tension||.5,n=h.datapoints.points,o=h.datapoints.pointsize,p=f.getPlotOffset(),q=n.length,r=[];if(c=[],4>q/o)return a.extend(h.lines,h.splines),void 0;for(k=0;q>k;k+=o)l=n[k],m=n[k+1],null==l||lh.xaxis.max||mh.yaxis.max||r.push(h.xaxis.p2c(l)+p.left,h.yaxis.p2c(m)+p.top);for(q=r.length,k=0;q-2>k;k+=2)i=i.concat(b.apply(this,r.slice(k,k+6).concat([j])));for(g.save(),g.strokeStyle=h.color,g.lineWidth=h.splines.lineWidth,e(g,"quadratic",r.slice(0,4),i.slice(0,2)),k=2;q-3>k;k+=2)e(g,"bezier",r.slice(k,k+4),i.slice(2*k-2,2*k+2));e(g,"quadratic",r.slice(q-2,q),[i[2*q-10],i[2*q-9],r[q-4],r[q-3]]),d(c,g,f.height()+10,h.splines.fill,h.color),g.restore()}}var c=[];a.plot.plugins.push({init:function(a){a.hooks.drawSeries.push(f)},options:{series:{splines:{show:!1,lineWidth:2,tension:.5,fill:!1}}},name:"spline",version:"0.8.2"})}(jQuery); \ No newline at end of file diff --git a/vendors/flot-spline/package.json b/vendors/flot-spline/package.json new file mode 100644 index 0000000..21ae099 --- /dev/null +++ b/vendors/flot-spline/package.json @@ -0,0 +1,13 @@ +{ + "name": "flot-spline", + "description": "Flot plugin that provides spline interpolation for line graphs", + "version": "0.0.1", + "homepage": "https://github.com/johnpozy/flot-spline", + "repository": "https://github.com/johnpozy/flot-spline", + "bugs": { + "url": "https://github.com/johnpozy/flot-spline/issues" + }, + "main": "js/jquery.flot.spline.js", + "license" : "SEE LICENSE IN LICENSE", + "devDependencies": {} +} diff --git a/vendors/flot.curvedlines/.bower.json b/vendors/flot.curvedlines/.bower.json new file mode 100644 index 0000000..7e3ccf3 --- /dev/null +++ b/vendors/flot.curvedlines/.bower.json @@ -0,0 +1,28 @@ +{ + "name": "flot.curvedlines", + "main": "curvedLines.js", + "authors": [ + "Michael Zinsmaier" + ], + "license": "MIT", + "ignore": [ + "**/*", + "!curvedLines.js", + "!bower.json" + ], + "dependencies": { + "flot": ">=0.8.0" + }, + "homepage": "https://github.com/MichaelZinsmaier/CurvedLines", + "version": "1.1.1", + "_release": "1.1.1", + "_resolution": { + "type": "version", + "tag": "1.1.1", + "commit": "2fbf588e8c1fc2cafad13fcc39b54aabb1f1e460" + }, + "_source": "https://github.com/MichaelZinsmaier/CurvedLines.git", + "_target": "^1.1.1", + "_originalSource": "flot.curvedlines", + "_direct": true +} \ No newline at end of file diff --git a/vendors/flot.curvedlines/bower.json b/vendors/flot.curvedlines/bower.json new file mode 100644 index 0000000..2915511 --- /dev/null +++ b/vendors/flot.curvedlines/bower.json @@ -0,0 +1,16 @@ +{ + "name": "flot.curvedlines", + "main": "curvedLines.js", + "authors": [ + "Michael Zinsmaier" + ], + "license": "MIT", + "ignore": [ + "**/*", + "!curvedLines.js", + "!bower.json" + ], + "dependencies": { + "flot": ">=0.8.0" + } +} diff --git a/production/js/flot/curvedLines.js b/vendors/flot.curvedlines/curvedLines.js old mode 100755 new mode 100644 similarity index 100% rename from production/js/flot/curvedLines.js rename to vendors/flot.curvedlines/curvedLines.js diff --git a/vendors/flot.orderbars/.bower.json b/vendors/flot.orderbars/.bower.json new file mode 100644 index 0000000..feb0aaf --- /dev/null +++ b/vendors/flot.orderbars/.bower.json @@ -0,0 +1,14 @@ +{ + "name": "flot.orderbars", + "homepage": "https://github.com/emmerich/flot-orderBars", + "_release": "9808145957", + "_resolution": { + "type": "branch", + "branch": "master", + "commit": "98081459571f60f7d95cc79a848c4f558d077486" + }, + "_source": "https://github.com/emmerich/flot-orderBars.git", + "_target": "*", + "_originalSource": "flot.orderbars", + "_direct": true +} \ No newline at end of file diff --git a/vendors/flot.orderbars/README.md b/vendors/flot.orderbars/README.md new file mode 100644 index 0000000..e21c7da --- /dev/null +++ b/vendors/flot.orderbars/README.md @@ -0,0 +1,36 @@ +flot-orderBars +============== + +Fork of the Flot OrderBars plugin found here: http://www.benjaminbuffet.com/public/js/jquery.flot.orderBars.js + +Improvements +============ + +### Compatability with Flot Stack Plugin +The main improvement I've made is compatability with the [Flot Stack plugin](https://github.com/flot/flot/blob/master/jquery.flot.stack.js). + +To use the 2 together: +* Ensure that your data is well formed. Each series should contain a bars object with an order integer, like so: +```javascript + var series = []; + + series.push({ + data: [], // your raw data + bars: { + order: 0 + } + }); + + series.push({ + data: [], // your raw data + bars: { + order: 1 + } + }); +``` + +* Ensure that the order bars plugin is loaded __before__ the stack plugin. + +See the example for more information. + + diff --git a/vendors/flot.orderbars/examples/index.html b/vendors/flot.orderbars/examples/index.html new file mode 100644 index 0000000..92784f1 --- /dev/null +++ b/vendors/flot.orderbars/examples/index.html @@ -0,0 +1,22 @@ + + + Flot Stacked and Ordered Bar Chart Examples + + + +

Stacked Bar Chart

+
+ +

Ordered Bar Chart

+
+ +

Stacked & Ordered Bar Chart

+
+ + + + + + + + diff --git a/vendors/flot.orderbars/examples/js/flot/flot.js b/vendors/flot.orderbars/examples/js/flot/flot.js new file mode 100644 index 0000000..31393ad --- /dev/null +++ b/vendors/flot.orderbars/examples/js/flot/flot.js @@ -0,0 +1,2635 @@ +/*! Javascript plotting library for jQuery, v. 0.7. + * + * Released under the MIT license by IOLA, December 2007. + * + */ + +// first an inline dependency, jquery.colorhelpers.js, we inline it here +// for convenience + +/* Plugin for jQuery for working with colors. + * + * Version 1.1. + * + * Inspiration from jQuery color animation plugin by John Resig. + * + * Released under the MIT license by Ole Laursen, October 2009. + * + * Examples: + * + * $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString() + * var c = $.color.extract($("#mydiv"), 'background-color'); + * console.log(c.r, c.g, c.b, c.a); + * $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)" + * + * Note that .scale() and .add() return the same modified object + * instead of making a new one. + * + * V. 1.1: Fix error handling so e.g. parsing an empty string does + * produce a color rather than just crashing. + */ +(function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return KI?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); + +// the actual Flot code +(function($) { + function Plot(placeholder, data_, options_, plugins) { + // data is on the form: + // [ series1, series2 ... ] + // where series is either just the data as [ [x1, y1], [x2, y2], ... ] + // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... } + + var series = [], + options = { + // the color theme used for graphs + colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"], + legend: { + show: true, + noColumns: 1, // number of colums in legend table + labelFormatter: null, // fn: string -> string + labelBoxBorderColor: "#ccc", // border color for the little label boxes + container: null, // container (as jQuery object) to put legend in, null means default on top of graph + position: "ne", // position of default legend container within plot + margin: 5, // distance from grid edge to default legend container within plot + backgroundColor: null, // null means auto-detect + backgroundOpacity: 0.85, // set to 0 to avoid background + reversed: false //default to not reversed order + }, + xaxis: { + show: null, // null = auto-detect, true = always, false = never + position: "bottom", // or "top" + mode: null, // null or "time" + color: null, // base color, labels, ticks + tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)" + transform: null, // null or f: number -> number to transform axis + inverseTransform: null, // if transform is set, this should be the inverse function + min: null, // min. value to show, null means set automatically + max: null, // max. value to show, null means set automatically + autoscaleMargin: null, // margin in % to add if auto-setting min/max + ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks + tickFormatter: null, // fn: number -> string + labelWidth: null, // size of tick labels in pixels + labelHeight: null, + reserveSpace: null, // whether to reserve space even if axis isn't shown + tickLength: null, // size in pixels of ticks, or "full" for whole line + alignTicksWithAxis: null, // axis number or null for no sync + + // mode specific options + tickDecimals: null, // no. of decimals, null means auto + tickSize: null, // number or [number, "unit"] + minTickSize: null, // number or [number, "unit"] + monthNames: null, // list of names of months + timeformat: null, // format string to use + twelveHourClock: false // 12 or 24 time in time mode + }, + yaxis: { + autoscaleMargin: 0.02, + position: "left" // or "right" + }, + xaxes: [], + yaxes: [], + series: { + points: { + show: false, + radius: 3, + lineWidth: 2, // in pixels + fill: true, + fillColor: "#ffffff", + symbol: "circle" // or callback + }, + lines: { + // we don't put in show: false so we can see + // whether lines were actively disabled + lineWidth: 2, // in pixels + fill: false, + fillColor: null, + steps: false + }, + bars: { + show: false, + lineWidth: 2, // in pixels + barWidth: 1, // in units of the x axis + fill: true, + fillColor: null, + align: "left", // or "center" + horizontal: false + }, + shadowSize: 3 + }, + grid: { + show: true, + aboveData: false, + color: "#545454", // primary color used for outline and labels + backgroundColor: null, // null for transparent, else color + borderColor: null, // set if different from the grid color + tickColor: null, // color for the ticks, e.g. "rgba(0,0,0,0.15)" + labelMargin: 5, // in pixels + axisMargin: 8, // in pixels + borderWidth: 2, // in pixels + minBorderMargin: null, // in pixels, null means taken from points radius + markings: null, // array of ranges or fn: axes -> array of ranges + markingsColor: "#f4f4f4", + markingsLineWidth: 2, + // interactive stuff + clickable: false, + hoverable: false, + autoHighlight: true, // highlight in case mouse is near + mouseActiveRadius: 10 // how far the mouse can be away to activate an item + }, + hooks: {} + }, + canvas = null, // the canvas for the plot itself + overlay = null, // canvas for interactive stuff on top of plot + eventHolder = null, // jQuery object that events should be bound to + ctx = null, octx = null, + xaxes = [], yaxes = [], + plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, + canvasWidth = 0, canvasHeight = 0, + plotWidth = 0, plotHeight = 0, + hooks = { + processOptions: [], + processRawData: [], + processDatapoints: [], + drawSeries: [], + draw: [], + bindEvents: [], + drawOverlay: [], + shutdown: [] + }, + plot = this; + + // public functions + plot.setData = setData; + plot.setupGrid = setupGrid; + plot.draw = draw; + plot.getPlaceholder = function() { return placeholder; }; + plot.getCanvas = function() { return canvas; }; + plot.getPlotOffset = function() { return plotOffset; }; + plot.width = function () { return plotWidth; }; + plot.height = function () { return plotHeight; }; + plot.offset = function () { + var o = eventHolder.offset(); + o.left += plotOffset.left; + o.top += plotOffset.top; + return o; + }; + plot.getData = function () { return series; }; + plot.getAxes = function () { + var res = {}, i; + $.each(xaxes.concat(yaxes), function (_, axis) { + if (axis) + res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis; + }); + return res; + }; + plot.getXAxes = function () { return xaxes; }; + plot.getYAxes = function () { return yaxes; }; + plot.c2p = canvasToAxisCoords; + plot.p2c = axisToCanvasCoords; + plot.getOptions = function () { return options; }; + plot.highlight = highlight; + plot.unhighlight = unhighlight; + plot.triggerRedrawOverlay = triggerRedrawOverlay; + plot.pointOffset = function(point) { + return { + left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left), + top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top) + }; + }; + plot.shutdown = shutdown; + plot.resize = function () { + getCanvasDimensions(); + resizeCanvas(canvas); + resizeCanvas(overlay); + }; + + // public attributes + plot.hooks = hooks; + + // initialize + initPlugins(plot); + parseOptions(options_); + setupCanvases(); + setData(data_); + setupGrid(); + draw(); + bindEvents(); + + + function executeHooks(hook, args) { + args = [plot].concat(args); + for (var i = 0; i < hook.length; ++i) + hook[i].apply(this, args); + } + + function initPlugins() { + for (var i = 0; i < plugins.length; ++i) { + var p = plugins[i]; + p.init(plot); + if (p.options) + $.extend(true, options, p.options); + } + } + + function parseOptions(opts) { + var i; + + $.extend(true, options, opts); + + if (options.xaxis.color == null) + options.xaxis.color = options.grid.color; + if (options.yaxis.color == null) + options.yaxis.color = options.grid.color; + + if (options.xaxis.tickColor == null) // backwards-compatibility + options.xaxis.tickColor = options.grid.tickColor; + if (options.yaxis.tickColor == null) // backwards-compatibility + options.yaxis.tickColor = options.grid.tickColor; + + if (options.grid.borderColor == null) + options.grid.borderColor = options.grid.color; + if (options.grid.tickColor == null) + options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString(); + + // fill in defaults in axes, copy at least always the + // first as the rest of the code assumes it'll be there + for (i = 0; i < Math.max(1, options.xaxes.length); ++i) + options.xaxes[i] = $.extend(true, {}, options.xaxis, options.xaxes[i]); + for (i = 0; i < Math.max(1, options.yaxes.length); ++i) + options.yaxes[i] = $.extend(true, {}, options.yaxis, options.yaxes[i]); + + // backwards compatibility, to be removed in future + if (options.xaxis.noTicks && options.xaxis.ticks == null) + options.xaxis.ticks = options.xaxis.noTicks; + if (options.yaxis.noTicks && options.yaxis.ticks == null) + options.yaxis.ticks = options.yaxis.noTicks; + if (options.x2axis) { + options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis); + options.xaxes[1].position = "top"; + } + if (options.y2axis) { + options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis); + options.yaxes[1].position = "right"; + } + if (options.grid.coloredAreas) + options.grid.markings = options.grid.coloredAreas; + if (options.grid.coloredAreasColor) + options.grid.markingsColor = options.grid.coloredAreasColor; + if (options.lines) + $.extend(true, options.series.lines, options.lines); + if (options.points) + $.extend(true, options.series.points, options.points); + if (options.bars) + $.extend(true, options.series.bars, options.bars); + if (options.shadowSize != null) + options.series.shadowSize = options.shadowSize; + + // save options on axes for future reference + for (i = 0; i < options.xaxes.length; ++i) + getOrCreateAxis(xaxes, i + 1).options = options.xaxes[i]; + for (i = 0; i < options.yaxes.length; ++i) + getOrCreateAxis(yaxes, i + 1).options = options.yaxes[i]; + + // add hooks from options + for (var n in hooks) + if (options.hooks[n] && options.hooks[n].length) + hooks[n] = hooks[n].concat(options.hooks[n]); + + executeHooks(hooks.processOptions, [options]); + } + + function setData(d) { + series = parseData(d); + fillInSeriesOptions(); + processData(); + } + + function parseData(d) { + var res = []; + for (var i = 0; i < d.length; ++i) { + var s = $.extend(true, {}, options.series); + + if (d[i].data != null) { + s.data = d[i].data; // move the data instead of deep-copy + delete d[i].data; + + $.extend(true, s, d[i]); + + d[i].data = s.data; + } + else + s.data = d[i]; + res.push(s); + } + + return res; + } + + function axisNumber(obj, coord) { + var a = obj[coord + "axis"]; + if (typeof a == "object") // if we got a real axis, extract number + a = a.n; + if (typeof a != "number") + a = 1; // default to first axis + return a; + } + + function allAxes() { + // return flat array without annoying null entries + return $.grep(xaxes.concat(yaxes), function (a) { return a; }); + } + + function canvasToAxisCoords(pos) { + // return an object with x/y corresponding to all used axes + var res = {}, i, axis; + for (i = 0; i < xaxes.length; ++i) { + axis = xaxes[i]; + if (axis && axis.used) + res["x" + axis.n] = axis.c2p(pos.left); + } + + for (i = 0; i < yaxes.length; ++i) { + axis = yaxes[i]; + if (axis && axis.used) + res["y" + axis.n] = axis.c2p(pos.top); + } + + if (res.x1 !== undefined) + res.x = res.x1; + if (res.y1 !== undefined) + res.y = res.y1; + + return res; + } + + function axisToCanvasCoords(pos) { + // get canvas coords from the first pair of x/y found in pos + var res = {}, i, axis, key; + + for (i = 0; i < xaxes.length; ++i) { + axis = xaxes[i]; + if (axis && axis.used) { + key = "x" + axis.n; + if (pos[key] == null && axis.n == 1) + key = "x"; + + if (pos[key] != null) { + res.left = axis.p2c(pos[key]); + break; + } + } + } + + for (i = 0; i < yaxes.length; ++i) { + axis = yaxes[i]; + if (axis && axis.used) { + key = "y" + axis.n; + if (pos[key] == null && axis.n == 1) + key = "y"; + + if (pos[key] != null) { + res.top = axis.p2c(pos[key]); + break; + } + } + } + + return res; + } + + function getOrCreateAxis(axes, number) { + if (!axes[number - 1]) + axes[number - 1] = { + n: number, // save the number for future reference + direction: axes == xaxes ? "x" : "y", + options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis) + }; + + return axes[number - 1]; + } + + function fillInSeriesOptions() { + var i; + + // collect what we already got of colors + var neededColors = series.length, + usedColors = [], + assignedColors = []; + for (i = 0; i < series.length; ++i) { + var sc = series[i].color; + if (sc != null) { + --neededColors; + if (typeof sc == "number") + assignedColors.push(sc); + else + usedColors.push($.color.parse(series[i].color)); + } + } + + // we might need to generate more colors if higher indices + // are assigned + for (i = 0; i < assignedColors.length; ++i) { + neededColors = Math.max(neededColors, assignedColors[i] + 1); + } + + // produce colors as needed + var colors = [], variation = 0; + i = 0; + while (colors.length < neededColors) { + var c; + if (options.colors.length == i) // check degenerate case + c = $.color.make(100, 100, 100); + else + c = $.color.parse(options.colors[i]); + + // vary color if needed + var sign = variation % 2 == 1 ? -1 : 1; + c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2) + + // FIXME: if we're getting to close to something else, + // we should probably skip this one + colors.push(c); + + ++i; + if (i >= options.colors.length) { + i = 0; + ++variation; + } + } + + // fill in the options + var colori = 0, s; + for (i = 0; i < series.length; ++i) { + s = series[i]; + + // assign colors + if (s.color == null) { + s.color = colors[colori].toString(); + ++colori; + } + else if (typeof s.color == "number") + s.color = colors[s.color].toString(); + + // turn on lines automatically in case nothing is set + if (s.lines.show == null) { + var v, show = true; + for (v in s) + if (s[v] && s[v].show) { + show = false; + break; + } + if (show) + s.lines.show = true; + } + + // setup axes + s.xaxis = getOrCreateAxis(xaxes, axisNumber(s, "x")); + s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y")); + } + } + + function processData() { + var topSentry = Number.POSITIVE_INFINITY, + bottomSentry = Number.NEGATIVE_INFINITY, + fakeInfinity = Number.MAX_VALUE, + i, j, k, m, length, + s, points, ps, x, y, axis, val, f, p; + + function updateAxis(axis, min, max) { + if (min < axis.datamin && min != -fakeInfinity) + axis.datamin = min; + if (max > axis.datamax && max != fakeInfinity) + axis.datamax = max; + } + + $.each(allAxes(), function (_, axis) { + // init axis + axis.datamin = topSentry; + axis.datamax = bottomSentry; + axis.used = false; + }); + + for (i = 0; i < series.length; ++i) { + s = series[i]; + s.datapoints = { points: [] }; + + executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]); + } + + // first pass: clean and copy data + for (i = 0; i < series.length; ++i) { + s = series[i]; + + var data = s.data, format = s.datapoints.format; + + if (!format) { + format = []; + // find out how to copy + format.push({ x: true, number: true, required: true }); + format.push({ y: true, number: true, required: true }); + + if (s.bars.show || (s.lines.show && s.lines.fill)) { + format.push({ y: true, number: true, required: false, defaultValue: 0 }); + if (s.bars.horizontal) { + delete format[format.length - 1].y; + format[format.length - 1].x = true; + } + } + + s.datapoints.format = format; + } + + if (s.datapoints.pointsize != null) + continue; // already filled in + + s.datapoints.pointsize = format.length; + + ps = s.datapoints.pointsize; + points = s.datapoints.points; + + insertSteps = s.lines.show && s.lines.steps; + s.xaxis.used = s.yaxis.used = true; + + for (j = k = 0; j < data.length; ++j, k += ps) { + p = data[j]; + + var nullify = p == null; + if (!nullify) { + for (m = 0; m < ps; ++m) { + val = p[m]; + f = format[m]; + + if (f) { + if (f.number && val != null) { + val = +val; // convert to number + if (isNaN(val)) + val = null; + else if (val == Infinity) + val = fakeInfinity; + else if (val == -Infinity) + val = -fakeInfinity; + } + + if (val == null) { + if (f.required) + nullify = true; + + if (f.defaultValue != null) + val = f.defaultValue; + } + } + + points[k + m] = val; + } + } + + if (nullify) { + for (m = 0; m < ps; ++m) { + val = points[k + m]; + if (val != null) { + f = format[m]; + // extract min/max info + if (f.x) + updateAxis(s.xaxis, val, val); + if (f.y) + updateAxis(s.yaxis, val, val); + } + points[k + m] = null; + } + } + else { + // a little bit of line specific stuff that + // perhaps shouldn't be here, but lacking + // better means... + if (insertSteps && k > 0 + && points[k - ps] != null + && points[k - ps] != points[k] + && points[k - ps + 1] != points[k + 1]) { + // copy the point to make room for a middle point + for (m = 0; m < ps; ++m) + points[k + ps + m] = points[k + m]; + + // middle point has same y + points[k + 1] = points[k - ps + 1]; + + // we've added a point, better reflect that + k += ps; + } + } + } + } + + // give the hooks a chance to run + for (i = 0; i < series.length; ++i) { + s = series[i]; + + executeHooks(hooks.processDatapoints, [ s, s.datapoints]); + } + + // second pass: find datamax/datamin for auto-scaling + for (i = 0; i < series.length; ++i) { + s = series[i]; + points = s.datapoints.points, + ps = s.datapoints.pointsize; + + var xmin = topSentry, ymin = topSentry, + xmax = bottomSentry, ymax = bottomSentry; + + for (j = 0; j < points.length; j += ps) { + if (points[j] == null) + continue; + + for (m = 0; m < ps; ++m) { + val = points[j + m]; + f = format[m]; + if (!f || val == fakeInfinity || val == -fakeInfinity) + continue; + + if (f.x) { + if (val < xmin) + xmin = val; + if (val > xmax) + xmax = val; + } + if (f.y) { + if (val < ymin) + ymin = val; + if (val > ymax) + ymax = val; + } + } + } + + if (s.bars.show) { + // make sure we got room for the bar on the dancing floor + var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2; + if (s.bars.horizontal) { + ymin += delta; + ymax += delta + s.bars.barWidth; + } + else { + xmin += delta; + xmax += delta + s.bars.barWidth; + } + } + + updateAxis(s.xaxis, xmin, xmax); + updateAxis(s.yaxis, ymin, ymax); + } + + $.each(allAxes(), function (_, axis) { + if (axis.datamin == topSentry) + axis.datamin = null; + if (axis.datamax == bottomSentry) + axis.datamax = null; + }); + } + + function makeCanvas(skipPositioning, cls) { + var c = document.createElement('canvas'); + + if(typeof FlashCanvas != "undefined") { + FlashCanvas.initElement(canvas); + } else if (!c.getContext) { // excanvas hack + //c = window.G_vmlCanvasManager.initElement(c); + window.G_vmlCanvasManager.initElement(c); + c.getContext('2d'); + } + + c.className = cls; + c.width = canvasWidth; + c.height = canvasHeight; + + if (!skipPositioning) + $(c).css({ position: 'absolute', left: 0, top: 0 }); + + $(c).appendTo(placeholder); + + // used for resetting in case we get replotted + c.getContext("2d").save(); + + return c; + } + + function getCanvasDimensions() { + canvasWidth = placeholder.width(); + canvasHeight = placeholder.height(); + + if (canvasWidth <= 0 || canvasHeight <= 0) + throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight; + } + + function resizeCanvas(c) { + // resizing should reset the state (excanvas seems to be + // buggy though) + if (c.width != canvasWidth) + c.width = canvasWidth; + + if (c.height != canvasHeight) + c.height = canvasHeight; + + // so try to get back to the initial state (even if it's + // gone now, this should be safe according to the spec) + var cctx = c.getContext("2d"); + cctx.restore(); + + // and save again + cctx.save(); + } + + function setupCanvases() { + var reused, + existingCanvas = placeholder.children("canvas.base"), + existingOverlay = placeholder.children("canvas.overlay"); + + if (existingCanvas.length == 0 || existingOverlay == 0) { + // init everything + + placeholder.html(""); // make sure placeholder is clear + + placeholder.css({ padding: 0 }); // padding messes up the positioning + + if (placeholder.css("position") == 'static') + placeholder.css("position", "relative"); // for positioning labels and overlay + + getCanvasDimensions(); + + canvas = makeCanvas(true, "base"); + overlay = makeCanvas(false, "overlay"); // overlay canvas for interactive features + + reused = false; + } + else { + // reuse existing elements + + canvas = existingCanvas.get(0); + overlay = existingOverlay.get(0); + + reused = true; + } + + ctx = canvas.getContext("2d"); + octx = overlay.getContext("2d"); + + // we include the canvas in the event holder too, because IE 7 + // sometimes has trouble with the stacking order + eventHolder = $([overlay, canvas]); + + if (reused) { + // run shutdown in the old plot object + placeholder.data("plot").shutdown(); + + // reset reused canvases + plot.resize(); + + // make sure overlay pixels are cleared (canvas is cleared when we redraw) + octx.clearRect(0, 0, canvasWidth, canvasHeight); + + // then whack any remaining obvious garbage left + eventHolder.unbind(); + placeholder.children().not([canvas, overlay]).remove(); + } + + // save in case we get replotted + placeholder.data("plot", plot); + } + + function bindEvents() { + // bind events + if (options.grid.hoverable) { + eventHolder.mousemove(onMouseMove); + eventHolder.mouseleave(onMouseLeave); + } + + if (options.grid.clickable) + eventHolder.click(onClick); + + executeHooks(hooks.bindEvents, [eventHolder]); + } + + function shutdown() { + if (redrawTimeout) + clearTimeout(redrawTimeout); + + eventHolder.unbind("mousemove", onMouseMove); + eventHolder.unbind("mouseleave", onMouseLeave); + eventHolder.unbind("click", onClick); + + executeHooks(hooks.shutdown, [eventHolder]); + } + + function setTransformationHelpers(axis) { + // set helper functions on the axis, assumes plot area + // has been computed already + + function identity(x) { return x; } + + var s, m, t = axis.options.transform || identity, + it = axis.options.inverseTransform; + + // precompute how much the axis is scaling a point + // in canvas space + if (axis.direction == "x") { + s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min)); + m = Math.min(t(axis.max), t(axis.min)); + } + else { + s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min)); + s = -s; + m = Math.max(t(axis.max), t(axis.min)); + } + + // data point to canvas coordinate + if (t == identity) // slight optimization + axis.p2c = function (p) { return (p - m) * s; }; + else + axis.p2c = function (p) { return (t(p) - m) * s; }; + // canvas coordinate to data point + if (!it) + axis.c2p = function (c) { return m + c / s; }; + else + axis.c2p = function (c) { return it(m + c / s); }; + } + + function measureTickLabels(axis) { + var opts = axis.options, i, ticks = axis.ticks || [], labels = [], + l, w = opts.labelWidth, h = opts.labelHeight, dummyDiv; + + function makeDummyDiv(labels, width) { + return $('
' + + '
' + + labels.join("") + '
') + .appendTo(placeholder); + } + + if (axis.direction == "x") { + // to avoid measuring the widths of the labels (it's slow), we + // construct fixed-size boxes and put the labels inside + // them, we don't need the exact figures and the + // fixed-size box content is easy to center + if (w == null) + w = Math.floor(canvasWidth / (ticks.length > 0 ? ticks.length : 1)); + + // measure x label heights + if (h == null) { + labels = []; + for (i = 0; i < ticks.length; ++i) { + l = ticks[i].label; + if (l) + labels.push('
' + l + '
'); + } + + if (labels.length > 0) { + // stick them all in the same div and measure + // collective height + labels.push('
'); + dummyDiv = makeDummyDiv(labels, "width:10000px;"); + h = dummyDiv.height(); + dummyDiv.remove(); + } + } + } + else if (w == null || h == null) { + // calculate y label dimensions + for (i = 0; i < ticks.length; ++i) { + l = ticks[i].label; + if (l) + labels.push('
' + l + '
'); + } + + if (labels.length > 0) { + dummyDiv = makeDummyDiv(labels, ""); + if (w == null) + w = dummyDiv.children().width(); + if (h == null) + h = dummyDiv.find("div.tickLabel").height(); + dummyDiv.remove(); + } + } + + if (w == null) + w = 0; + if (h == null) + h = 0; + + axis.labelWidth = w; + axis.labelHeight = h; + } + + function allocateAxisBoxFirstPhase(axis) { + // find the bounding box of the axis by looking at label + // widths/heights and ticks, make room by diminishing the + // plotOffset + + var lw = axis.labelWidth, + lh = axis.labelHeight, + pos = axis.options.position, + tickLength = axis.options.tickLength, + axismargin = options.grid.axisMargin, + padding = options.grid.labelMargin, + all = axis.direction == "x" ? xaxes : yaxes, + index; + + // determine axis margin + var samePosition = $.grep(all, function (a) { + return a && a.options.position == pos && a.reserveSpace; + }); + if ($.inArray(axis, samePosition) == samePosition.length - 1) + axismargin = 0; // outermost + + // determine tick length - if we're innermost, we can use "full" + if (tickLength == null) + tickLength = "full"; + + var sameDirection = $.grep(all, function (a) { + return a && a.reserveSpace; + }); + + var innermost = $.inArray(axis, sameDirection) == 0; + if (!innermost && tickLength == "full") + tickLength = 5; + + if (!isNaN(+tickLength)) + padding += +tickLength; + + // compute box + if (axis.direction == "x") { + lh += padding; + + if (pos == "bottom") { + plotOffset.bottom += lh + axismargin; + axis.box = { top: canvasHeight - plotOffset.bottom, height: lh }; + } + else { + axis.box = { top: plotOffset.top + axismargin, height: lh }; + plotOffset.top += lh + axismargin; + } + } + else { + lw += padding; + + if (pos == "left") { + axis.box = { left: plotOffset.left + axismargin, width: lw }; + plotOffset.left += lw + axismargin; + } + else { + plotOffset.right += lw + axismargin; + axis.box = { left: canvasWidth - plotOffset.right, width: lw }; + } + } + + // save for future reference + axis.position = pos; + axis.tickLength = tickLength; + axis.box.padding = padding; + axis.innermost = innermost; + } + + function allocateAxisBoxSecondPhase(axis) { + // set remaining bounding box coordinates + if (axis.direction == "x") { + axis.box.left = plotOffset.left; + axis.box.width = plotWidth; + } + else { + axis.box.top = plotOffset.top; + axis.box.height = plotHeight; + } + } + + function setupGrid() { + var i, axes = allAxes(); + + // first calculate the plot and axis box dimensions + + $.each(axes, function (_, axis) { + axis.show = axis.options.show; + if (axis.show == null) + axis.show = axis.used; // by default an axis is visible if it's got data + + axis.reserveSpace = axis.show || axis.options.reserveSpace; + + setRange(axis); + }); + + allocatedAxes = $.grep(axes, function (axis) { return axis.reserveSpace; }); + + plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0; + if (options.grid.show) { + $.each(allocatedAxes, function (_, axis) { + // make the ticks + setupTickGeneration(axis); + setTicks(axis); + snapRangeToTicks(axis, axis.ticks); + + // find labelWidth/Height for axis + measureTickLabels(axis); + }); + + // with all dimensions in house, we can compute the + // axis boxes, start from the outside (reverse order) + for (i = allocatedAxes.length - 1; i >= 0; --i) + allocateAxisBoxFirstPhase(allocatedAxes[i]); + + // make sure we've got enough space for things that + // might stick out + var minMargin = options.grid.minBorderMargin; + if (minMargin == null) { + minMargin = 0; + for (i = 0; i < series.length; ++i) + minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2); + } + + for (var a in plotOffset) { + plotOffset[a] += options.grid.borderWidth; + plotOffset[a] = Math.max(minMargin, plotOffset[a]); + } + } + + plotWidth = canvasWidth - plotOffset.left - plotOffset.right; + plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top; + + // now we got the proper plotWidth/Height, we can compute the scaling + $.each(axes, function (_, axis) { + setTransformationHelpers(axis); + }); + + if (options.grid.show) { + $.each(allocatedAxes, function (_, axis) { + allocateAxisBoxSecondPhase(axis); + }); + + insertAxisLabels(); + } + + insertLegend(); + } + + function setRange(axis) { + var opts = axis.options, + min = +(opts.min != null ? opts.min : axis.datamin), + max = +(opts.max != null ? opts.max : axis.datamax), + delta = max - min; + + if (delta == 0.0) { + // degenerate case + var widen = max == 0 ? 1 : 0.01; + + if (opts.min == null) + min -= widen; + // always widen max if we couldn't widen min to ensure we + // don't fall into min == max which doesn't work + if (opts.max == null || opts.min != null) + max += widen; + } + else { + // consider autoscaling + var margin = opts.autoscaleMargin; + if (margin != null) { + if (opts.min == null) { + min -= delta * margin; + // make sure we don't go below zero if all values + // are positive + if (min < 0 && axis.datamin != null && axis.datamin >= 0) + min = 0; + } + if (opts.max == null) { + max += delta * margin; + if (max > 0 && axis.datamax != null && axis.datamax <= 0) + max = 0; + } + } + } + axis.min = min; + axis.max = max; + } + + function setupTickGeneration(axis) { + var opts = axis.options; + + // estimate number of ticks + var noTicks; + if (typeof opts.ticks == "number" && opts.ticks > 0) + noTicks = opts.ticks; + else + // heuristic based on the model a*sqrt(x) fitted to + // some data points that seemed reasonable + noTicks = 0.3 * Math.sqrt(axis.direction == "x" ? canvasWidth : canvasHeight); + + var delta = (axis.max - axis.min) / noTicks, + size, generator, unit, formatter, i, magn, norm; + + if (opts.mode == "time") { + // pretty handling of time + + // map of app. size of time units in milliseconds + var timeUnitSize = { + "second": 1000, + "minute": 60 * 1000, + "hour": 60 * 60 * 1000, + "day": 24 * 60 * 60 * 1000, + "month": 30 * 24 * 60 * 60 * 1000, + "year": 365.2425 * 24 * 60 * 60 * 1000 + }; + + + // the allowed tick sizes, after 1 year we use + // an integer algorithm + var spec = [ + [1, "second"], [2, "second"], [5, "second"], [10, "second"], + [30, "second"], + [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"], + [30, "minute"], + [1, "hour"], [2, "hour"], [4, "hour"], + [8, "hour"], [12, "hour"], + [1, "day"], [2, "day"], [3, "day"], + [0.25, "month"], [0.5, "month"], [1, "month"], + [2, "month"], [3, "month"], [6, "month"], + [1, "year"] + ]; + + var minSize = 0; + if (opts.minTickSize != null) { + if (typeof opts.tickSize == "number") + minSize = opts.tickSize; + else + minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]]; + } + + for (var i = 0; i < spec.length - 1; ++i) + if (delta < (spec[i][0] * timeUnitSize[spec[i][1]] + + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2 + && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize) + break; + size = spec[i][0]; + unit = spec[i][1]; + + // special-case the possibility of several years + if (unit == "year") { + magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10)); + norm = (delta / timeUnitSize.year) / magn; + if (norm < 1.5) + size = 1; + else if (norm < 3) + size = 2; + else if (norm < 7.5) + size = 5; + else + size = 10; + + size *= magn; + } + + axis.tickSize = opts.tickSize || [size, unit]; + + generator = function(axis) { + var ticks = [], + tickSize = axis.tickSize[0], unit = axis.tickSize[1], + d = new Date(axis.min); + + var step = tickSize * timeUnitSize[unit]; + + if (unit == "second") + d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize)); + if (unit == "minute") + d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize)); + if (unit == "hour") + d.setUTCHours(floorInBase(d.getUTCHours(), tickSize)); + if (unit == "month") + d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize)); + if (unit == "year") + d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize)); + + // reset smaller components + d.setUTCMilliseconds(0); + if (step >= timeUnitSize.minute) + d.setUTCSeconds(0); + if (step >= timeUnitSize.hour) + d.setUTCMinutes(0); + if (step >= timeUnitSize.day) + d.setUTCHours(0); + if (step >= timeUnitSize.day * 4) + d.setUTCDate(1); + if (step >= timeUnitSize.year) + d.setUTCMonth(0); + + + var carry = 0, v = Number.NaN, prev; + do { + prev = v; + v = d.getTime(); + ticks.push(v); + if (unit == "month") { + if (tickSize < 1) { + // a bit complicated - we'll divide the month + // up but we need to take care of fractions + // so we don't end up in the middle of a day + d.setUTCDate(1); + var start = d.getTime(); + d.setUTCMonth(d.getUTCMonth() + 1); + var end = d.getTime(); + d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize); + carry = d.getUTCHours(); + d.setUTCHours(0); + } + else + d.setUTCMonth(d.getUTCMonth() + tickSize); + } + else if (unit == "year") { + d.setUTCFullYear(d.getUTCFullYear() + tickSize); + } + else + d.setTime(v + step); + } while (v < axis.max && v != prev); + + return ticks; + }; + + formatter = function (v, axis) { + var d = new Date(v); + + // first check global format + if (opts.timeformat != null) + return $.plot.formatDate(d, opts.timeformat, opts.monthNames); + + var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]]; + var span = axis.max - axis.min; + var suffix = (opts.twelveHourClock) ? " %p" : ""; + + if (t < timeUnitSize.minute) + fmt = "%h:%M:%S" + suffix; + else if (t < timeUnitSize.day) { + if (span < 2 * timeUnitSize.day) + fmt = "%h:%M" + suffix; + else + fmt = "%b %d %h:%M" + suffix; + } + else if (t < timeUnitSize.month) + fmt = "%b %d"; + else if (t < timeUnitSize.year) { + if (span < timeUnitSize.year) + fmt = "%b"; + else + fmt = "%b %y"; + } + else + fmt = "%y"; + + return $.plot.formatDate(d, fmt, opts.monthNames); + }; + } + else { + // pretty rounding of base-10 numbers + var maxDec = opts.tickDecimals; + var dec = -Math.floor(Math.log(delta) / Math.LN10); + if (maxDec != null && dec > maxDec) + dec = maxDec; + + magn = Math.pow(10, -dec); + norm = delta / magn; // norm is between 1.0 and 10.0 + + if (norm < 1.5) + size = 1; + else if (norm < 3) { + size = 2; + // special case for 2.5, requires an extra decimal + if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) { + size = 2.5; + ++dec; + } + } + else if (norm < 7.5) + size = 5; + else + size = 10; + + size *= magn; + + if (opts.minTickSize != null && size < opts.minTickSize) + size = opts.minTickSize; + + axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec); + axis.tickSize = opts.tickSize || size; + + generator = function (axis) { + var ticks = []; + + // spew out all possible ticks + var start = floorInBase(axis.min, axis.tickSize), + i = 0, v = Number.NaN, prev; + do { + prev = v; + v = start + i * axis.tickSize; + ticks.push(v); + ++i; + } while (v < axis.max && v != prev); + return ticks; + }; + + formatter = function (v, axis) { + return v.toFixed(axis.tickDecimals); + }; + } + + if (opts.alignTicksWithAxis != null) { + var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1]; + if (otherAxis && otherAxis.used && otherAxis != axis) { + // consider snapping min/max to outermost nice ticks + var niceTicks = generator(axis); + if (niceTicks.length > 0) { + if (opts.min == null) + axis.min = Math.min(axis.min, niceTicks[0]); + if (opts.max == null && niceTicks.length > 1) + axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]); + } + + generator = function (axis) { + // copy ticks, scaled to this axis + var ticks = [], v, i; + for (i = 0; i < otherAxis.ticks.length; ++i) { + v = (otherAxis.ticks[i].v - otherAxis.min) / (otherAxis.max - otherAxis.min); + v = axis.min + v * (axis.max - axis.min); + ticks.push(v); + } + return ticks; + }; + + // we might need an extra decimal since forced + // ticks don't necessarily fit naturally + if (axis.mode != "time" && opts.tickDecimals == null) { + var extraDec = Math.max(0, -Math.floor(Math.log(delta) / Math.LN10) + 1), + ts = generator(axis); + + // only proceed if the tick interval rounded + // with an extra decimal doesn't give us a + // zero at end + if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec)))) + axis.tickDecimals = extraDec; + } + } + } + + axis.tickGenerator = generator; + if ($.isFunction(opts.tickFormatter)) + axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); }; + else + axis.tickFormatter = formatter; + } + + function setTicks(axis) { + var oticks = axis.options.ticks, ticks = []; + if (oticks == null || (typeof oticks == "number" && oticks > 0)) + ticks = axis.tickGenerator(axis); + else if (oticks) { + if ($.isFunction(oticks)) + // generate the ticks + ticks = oticks({ min: axis.min, max: axis.max }); + else + ticks = oticks; + } + + // clean up/labelify the supplied ticks, copy them over + var i, v; + axis.ticks = []; + for (i = 0; i < ticks.length; ++i) { + var label = null; + var t = ticks[i]; + if (typeof t == "object") { + v = +t[0]; + if (t.length > 1) + label = t[1]; + } + else + v = +t; + if (label == null) + label = axis.tickFormatter(v, axis); + if (!isNaN(v)) + axis.ticks.push({ v: v, label: label }); + } + } + + function snapRangeToTicks(axis, ticks) { + if (axis.options.autoscaleMargin && ticks.length > 0) { + // snap to ticks + if (axis.options.min == null) + axis.min = Math.min(axis.min, ticks[0].v); + if (axis.options.max == null && ticks.length > 1) + axis.max = Math.max(axis.max, ticks[ticks.length - 1].v); + } + } + + function draw() { + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + + var grid = options.grid; + + // draw background, if any + if (grid.show && grid.backgroundColor) + drawBackground(); + + if (grid.show && !grid.aboveData) + drawGrid(); + + for (var i = 0; i < series.length; ++i) { + executeHooks(hooks.drawSeries, [ctx, series[i]]); + drawSeries(series[i]); + } + + executeHooks(hooks.draw, [ctx]); + + if (grid.show && grid.aboveData) + drawGrid(); + } + + function extractRange(ranges, coord) { + var axis, from, to, key, axes = allAxes(); + + for (i = 0; i < axes.length; ++i) { + axis = axes[i]; + if (axis.direction == coord) { + key = coord + axis.n + "axis"; + if (!ranges[key] && axis.n == 1) + key = coord + "axis"; // support x1axis as xaxis + if (ranges[key]) { + from = ranges[key].from; + to = ranges[key].to; + break; + } + } + } + + // backwards-compat stuff - to be removed in future + if (!ranges[key]) { + axis = coord == "x" ? xaxes[0] : yaxes[0]; + from = ranges[coord + "1"]; + to = ranges[coord + "2"]; + } + + // auto-reverse as an added bonus + if (from != null && to != null && from > to) { + var tmp = from; + from = to; + to = tmp; + } + + return { from: from, to: to, axis: axis }; + } + + function drawBackground() { + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)"); + ctx.fillRect(0, 0, plotWidth, plotHeight); + ctx.restore(); + } + + function drawGrid() { + var i; + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + // draw markings + var markings = options.grid.markings; + if (markings) { + if ($.isFunction(markings)) { + var axes = plot.getAxes(); + // xmin etc. is backwards compatibility, to be + // removed in the future + axes.xmin = axes.xaxis.min; + axes.xmax = axes.xaxis.max; + axes.ymin = axes.yaxis.min; + axes.ymax = axes.yaxis.max; + + markings = markings(axes); + } + + for (i = 0; i < markings.length; ++i) { + var m = markings[i], + xrange = extractRange(m, "x"), + yrange = extractRange(m, "y"); + + // fill in missing + if (xrange.from == null) + xrange.from = xrange.axis.min; + if (xrange.to == null) + xrange.to = xrange.axis.max; + if (yrange.from == null) + yrange.from = yrange.axis.min; + if (yrange.to == null) + yrange.to = yrange.axis.max; + + // clip + if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max || + yrange.to < yrange.axis.min || yrange.from > yrange.axis.max) + continue; + + xrange.from = Math.max(xrange.from, xrange.axis.min); + xrange.to = Math.min(xrange.to, xrange.axis.max); + yrange.from = Math.max(yrange.from, yrange.axis.min); + yrange.to = Math.min(yrange.to, yrange.axis.max); + + if (xrange.from == xrange.to && yrange.from == yrange.to) + continue; + + // then draw + xrange.from = xrange.axis.p2c(xrange.from); + xrange.to = xrange.axis.p2c(xrange.to); + yrange.from = yrange.axis.p2c(yrange.from); + yrange.to = yrange.axis.p2c(yrange.to); + + if (xrange.from == xrange.to || yrange.from == yrange.to) { + // draw line + ctx.beginPath(); + ctx.strokeStyle = m.color || options.grid.markingsColor; + ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth; + ctx.moveTo(xrange.from, yrange.from); + ctx.lineTo(xrange.to, yrange.to); + ctx.stroke(); + } + else { + // fill area + ctx.fillStyle = m.color || options.grid.markingsColor; + ctx.fillRect(xrange.from, yrange.to, + xrange.to - xrange.from, + yrange.from - yrange.to); + } + } + } + + // draw the ticks + var axes = allAxes(), bw = options.grid.borderWidth; + + for (var j = 0; j < axes.length; ++j) { + var axis = axes[j], box = axis.box, + t = axis.tickLength, x, y, xoff, yoff; + if (!axis.show || axis.ticks.length == 0) + continue + + ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString(); + ctx.lineWidth = 1; + + // find the edges + if (axis.direction == "x") { + x = 0; + if (t == "full") + y = (axis.position == "top" ? 0 : plotHeight); + else + y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0); + } + else { + y = 0; + if (t == "full") + x = (axis.position == "left" ? 0 : plotWidth); + else + x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0); + } + + // draw tick bar + if (!axis.innermost) { + ctx.beginPath(); + xoff = yoff = 0; + if (axis.direction == "x") + xoff = plotWidth; + else + yoff = plotHeight; + + if (ctx.lineWidth == 1) { + x = Math.floor(x) + 0.5; + y = Math.floor(y) + 0.5; + } + + ctx.moveTo(x, y); + ctx.lineTo(x + xoff, y + yoff); + ctx.stroke(); + } + + // draw ticks + ctx.beginPath(); + for (i = 0; i < axis.ticks.length; ++i) { + var v = axis.ticks[i].v; + + xoff = yoff = 0; + + if (v < axis.min || v > axis.max + // skip those lying on the axes if we got a border + || (t == "full" && bw > 0 + && (v == axis.min || v == axis.max))) + continue; + + if (axis.direction == "x") { + x = axis.p2c(v); + yoff = t == "full" ? -plotHeight : t; + + if (axis.position == "top") + yoff = -yoff; + } + else { + y = axis.p2c(v); + xoff = t == "full" ? -plotWidth : t; + + if (axis.position == "left") + xoff = -xoff; + } + + if (ctx.lineWidth == 1) { + if (axis.direction == "x") + x = Math.floor(x) + 0.5; + else + y = Math.floor(y) + 0.5; + } + + ctx.moveTo(x, y); + ctx.lineTo(x + xoff, y + yoff); + } + + ctx.stroke(); + } + + + // draw border + if (bw) { + ctx.lineWidth = bw; + ctx.strokeStyle = options.grid.borderColor; + ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw); + } + + ctx.restore(); + } + + function insertAxisLabels() { + placeholder.find(".tickLabels").remove(); + + var html = ['
']; + + var axes = allAxes(); + for (var j = 0; j < axes.length; ++j) { + var axis = axes[j], box = axis.box; + if (!axis.show) + continue; + //debug: html.push('
') + html.push('
'); + for (var i = 0; i < axis.ticks.length; ++i) { + var tick = axis.ticks[i]; + if (!tick.label || tick.v < axis.min || tick.v > axis.max) + continue; + + var pos = {}, align; + + if (axis.direction == "x") { + align = "center"; + pos.left = Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2); + if (axis.position == "bottom") + pos.top = box.top + box.padding; + else + pos.bottom = canvasHeight - (box.top + box.height - box.padding); + } + else { + pos.top = Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2); + if (axis.position == "left") { + pos.right = canvasWidth - (box.left + box.width - box.padding) + align = "right"; + } + else { + pos.left = box.left + box.padding; + align = "left"; + } + } + + pos.width = axis.labelWidth; + + var style = ["position:absolute", "text-align:" + align ]; + for (var a in pos) + style.push(a + ":" + pos[a] + "px") + + html.push('
' + tick.label + '
'); + } + html.push('
'); + } + + html.push('
'); + + placeholder.append(html.join("")); + } + + function drawSeries(series) { + if (series.lines.show) + drawSeriesLines(series); + if (series.bars.show) + drawSeriesBars(series); + if (series.points.show) + drawSeriesPoints(series); + } + + function drawSeriesLines(series) { + function plotLine(datapoints, xoffset, yoffset, axisx, axisy) { + var points = datapoints.points, + ps = datapoints.pointsize, + prevx = null, prevy = null; + + ctx.beginPath(); + for (var i = ps; i < points.length; i += ps) { + var x1 = points[i - ps], y1 = points[i - ps + 1], + x2 = points[i], y2 = points[i + 1]; + + if (x1 == null || x2 == null) + continue; + + // clip with ymin + if (y1 <= y2 && y1 < axisy.min) { + if (y2 < axisy.min) + continue; // line segment is outside + // compute new intersection point + x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.min; + } + else if (y2 <= y1 && y2 < axisy.min) { + if (y1 < axisy.min) + continue; + x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.min; + } + + // clip with ymax + if (y1 >= y2 && y1 > axisy.max) { + if (y2 > axisy.max) + continue; + x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.max; + } + else if (y2 >= y1 && y2 > axisy.max) { + if (y1 > axisy.max) + continue; + x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.max; + } + + // clip with xmin + if (x1 <= x2 && x1 < axisx.min) { + if (x2 < axisx.min) + continue; + y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.min; + } + else if (x2 <= x1 && x2 < axisx.min) { + if (x1 < axisx.min) + continue; + y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.min; + } + + // clip with xmax + if (x1 >= x2 && x1 > axisx.max) { + if (x2 > axisx.max) + continue; + y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.max; + } + else if (x2 >= x1 && x2 > axisx.max) { + if (x1 > axisx.max) + continue; + y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.max; + } + + if (x1 != prevx || y1 != prevy) + ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset); + + prevx = x2; + prevy = y2; + ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset); + } + ctx.stroke(); + } + + function plotLineArea(datapoints, axisx, axisy) { + var points = datapoints.points, + ps = datapoints.pointsize, + bottom = Math.min(Math.max(0, axisy.min), axisy.max), + i = 0, top, areaOpen = false, + ypos = 1, segmentStart = 0, segmentEnd = 0; + + // we process each segment in two turns, first forward + // direction to sketch out top, then once we hit the + // end we go backwards to sketch the bottom + while (true) { + if (ps > 0 && i > points.length + ps) + break; + + i += ps; // ps is negative if going backwards + + var x1 = points[i - ps], + y1 = points[i - ps + ypos], + x2 = points[i], y2 = points[i + ypos]; + + if (areaOpen) { + if (ps > 0 && x1 != null && x2 == null) { + // at turning point + segmentEnd = i; + ps = -ps; + ypos = 2; + continue; + } + + if (ps < 0 && i == segmentStart + ps) { + // done with the reverse sweep + ctx.fill(); + areaOpen = false; + ps = -ps; + ypos = 1; + i = segmentStart = segmentEnd + ps; + continue; + } + } + + if (x1 == null || x2 == null) + continue; + + // clip x values + + // clip with xmin + if (x1 <= x2 && x1 < axisx.min) { + if (x2 < axisx.min) + continue; + y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.min; + } + else if (x2 <= x1 && x2 < axisx.min) { + if (x1 < axisx.min) + continue; + y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.min; + } + + // clip with xmax + if (x1 >= x2 && x1 > axisx.max) { + if (x2 > axisx.max) + continue; + y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.max; + } + else if (x2 >= x1 && x2 > axisx.max) { + if (x1 > axisx.max) + continue; + y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.max; + } + + if (!areaOpen) { + // open area + ctx.beginPath(); + ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom)); + areaOpen = true; + } + + // now first check the case where both is outside + if (y1 >= axisy.max && y2 >= axisy.max) { + ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max)); + continue; + } + else if (y1 <= axisy.min && y2 <= axisy.min) { + ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min)); + continue; + } + + // else it's a bit more complicated, there might + // be a flat maxed out rectangle first, then a + // triangular cutout or reverse; to find these + // keep track of the current x values + var x1old = x1, x2old = x2; + + // clip the y values, without shortcutting, we + // go through all cases in turn + + // clip with ymin + if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) { + x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.min; + } + else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) { + x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.min; + } + + // clip with ymax + if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) { + x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.max; + } + else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) { + x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.max; + } + + // if the x value was changed we got a rectangle + // to fill + if (x1 != x1old) { + ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1)); + // it goes to (x1, y1), but we fill that below + } + + // fill triangular section, this sometimes result + // in redundant points if (x1, y1) hasn't changed + // from previous line to, but we just ignore that + ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2)); + + // fill the other rectangle if it's there + if (x2 != x2old) { + ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2)); + ctx.lineTo(axisx.p2c(x2old), axisy.p2c(y2)); + } + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + ctx.lineJoin = "round"; + + var lw = series.lines.lineWidth, + sw = series.shadowSize; + // FIXME: consider another form of shadow when filling is turned on + if (lw > 0 && sw > 0) { + // draw shadow as a thick and thin line with transparency + ctx.lineWidth = sw; + ctx.strokeStyle = "rgba(0,0,0,0.1)"; + // position shadow at angle from the mid of line + var angle = Math.PI/18; + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis); + ctx.lineWidth = sw/2; + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis); + } + + ctx.lineWidth = lw; + ctx.strokeStyle = series.color; + var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight); + if (fillStyle) { + ctx.fillStyle = fillStyle; + plotLineArea(series.datapoints, series.xaxis, series.yaxis); + } + + if (lw > 0) + plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis); + ctx.restore(); + } + + function drawSeriesPoints(series) { + function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol) { + var points = datapoints.points, ps = datapoints.pointsize; + + for (var i = 0; i < points.length; i += ps) { + var x = points[i], y = points[i + 1]; + if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) + continue; + + ctx.beginPath(); + x = axisx.p2c(x); + y = axisy.p2c(y) + offset; + if (symbol == "circle") + ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false); + else + symbol(ctx, x, y, radius, shadow); + ctx.closePath(); + + if (fillStyle) { + ctx.fillStyle = fillStyle; + ctx.fill(); + } + ctx.stroke(); + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + var lw = series.points.lineWidth, + sw = series.shadowSize, + radius = series.points.radius, + symbol = series.points.symbol; + if (lw > 0 && sw > 0) { + // draw shadow in two steps + var w = sw / 2; + ctx.lineWidth = w; + ctx.strokeStyle = "rgba(0,0,0,0.1)"; + plotPoints(series.datapoints, radius, null, w + w/2, true, + series.xaxis, series.yaxis, symbol); + + ctx.strokeStyle = "rgba(0,0,0,0.2)"; + plotPoints(series.datapoints, radius, null, w/2, true, + series.xaxis, series.yaxis, symbol); + } + + ctx.lineWidth = lw; + ctx.strokeStyle = series.color; + plotPoints(series.datapoints, radius, + getFillStyle(series.points, series.color), 0, false, + series.xaxis, series.yaxis, symbol); + ctx.restore(); + } + + function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) { + var left, right, bottom, top, + drawLeft, drawRight, drawTop, drawBottom, + tmp; + + // in horizontal mode, we start the bar from the left + // instead of from the bottom so it appears to be + // horizontal rather than vertical + if (horizontal) { + drawBottom = drawRight = drawTop = true; + drawLeft = false; + left = b; + right = x; + top = y + barLeft; + bottom = y + barRight; + + // account for negative bars + if (right < left) { + tmp = right; + right = left; + left = tmp; + drawLeft = true; + drawRight = false; + } + } + else { + drawLeft = drawRight = drawTop = true; + drawBottom = false; + left = x + barLeft; + right = x + barRight; + bottom = b; + top = y; + + // account for negative bars + if (top < bottom) { + tmp = top; + top = bottom; + bottom = tmp; + drawBottom = true; + drawTop = false; + } + } + + // clip + if (right < axisx.min || left > axisx.max || + top < axisy.min || bottom > axisy.max) + return; + + if (left < axisx.min) { + left = axisx.min; + drawLeft = false; + } + + if (right > axisx.max) { + right = axisx.max; + drawRight = false; + } + + if (bottom < axisy.min) { + bottom = axisy.min; + drawBottom = false; + } + + if (top > axisy.max) { + top = axisy.max; + drawTop = false; + } + + left = axisx.p2c(left); + bottom = axisy.p2c(bottom); + right = axisx.p2c(right); + top = axisy.p2c(top); + + // fill the bar + if (fillStyleCallback) { + c.beginPath(); + c.moveTo(left, bottom); + c.lineTo(left, top); + c.lineTo(right, top); + c.lineTo(right, bottom); + c.fillStyle = fillStyleCallback(bottom, top); + c.fill(); + } + + // draw outline + if (lineWidth > 0 && (drawLeft || drawRight || drawTop || drawBottom)) { + c.beginPath(); + + // FIXME: inline moveTo is buggy with excanvas + c.moveTo(left, bottom + offset); + if (drawLeft) + c.lineTo(left, top + offset); + else + c.moveTo(left, top + offset); + if (drawTop) + c.lineTo(right, top + offset); + else + c.moveTo(right, top + offset); + if (drawRight) + c.lineTo(right, bottom + offset); + else + c.moveTo(right, bottom + offset); + if (drawBottom) + c.lineTo(left, bottom + offset); + else + c.moveTo(left, bottom + offset); + c.stroke(); + } + } + + function drawSeriesBars(series) { + function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) { + var points = datapoints.points, ps = datapoints.pointsize, + extendedFillStyleCallback = null; + + for (var i = 0; i < points.length; i += ps) { + if (points[i] == null) + continue; + + if(fillStyleCallback) { + extendedFillStyleCallback = function(top, bottom) { + return fillStyleCallback(top, bottom, i/ps); + } + } + + drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, extendedFillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth); + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + // FIXME: figure out a way to add shadows (for instance along the right edge) + ctx.lineWidth = series.bars.lineWidth; + ctx.strokeStyle = series.color; + var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; + var fillStyleCallback = null; + + if(series.bars.fill) { + if(series.bars.fillCallback) { + fillStyleCallback = function(bottom, top, dataIndex) { + var customConfiguration = $.extend(true, {}, series, series.bars.fillCallback(bottom, top, dataIndex)); + return getFillStyle(customConfiguration.bars, customConfiguration.color, bottom, top); + } + } else { + fillStyleCallback = function(bottom, top) { + return getFillStyle(series.bars, series.color, bottom, top) + } + } + } + + plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis); + ctx.restore(); + } + + function getFillStyle(filloptions, seriesColor, bottom, top) { + var fill = filloptions.fill; + if (!fill) + return null; + + if (filloptions.fillColor) + return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor); + + var c = $.color.parse(seriesColor); + c.a = typeof fill == "number" ? fill : 0.4; + c.normalize(); + return c.toString(); + } + + function insertLegend() { + placeholder.find(".legend").remove(); + + if (!options.legend.show) + return; + + var fragments = [], rowStarted = false, + lf = options.legend.labelFormatter, s, label; + for (var i = 0; i < series.length; ++i) { + s = series[i]; + label = s.label; + if (!label) + continue; + + if (i % options.legend.noColumns == 0) { + if (rowStarted) + fragments.push(''); + fragments.push(''); + rowStarted = true; + } + + if (lf) + label = lf(label, s); + + fragments.push( + '
' + + '' + label + ''); + } + if (rowStarted) + fragments.push(''); + + if(options.legend.reversed) { + fragments.reverse(); + } + + if (fragments.length == 0) + return; + + var table = '' + fragments.join("") + '
'; + if (options.legend.container != null) + $(options.legend.container).html(table); + else { + var pos = "", + p = options.legend.position, + m = options.legend.margin; + if (m[0] == null) + m = [m, m]; + if (p.charAt(0) == "n") + pos += 'top:' + (m[1] + plotOffset.top) + 'px;'; + else if (p.charAt(0) == "s") + pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;'; + if (p.charAt(1) == "e") + pos += 'right:' + (m[0] + plotOffset.right) + 'px;'; + else if (p.charAt(1) == "w") + pos += 'left:' + (m[0] + plotOffset.left) + 'px;'; + var legend = $('
' + table.replace('style="', 'style="position:absolute;' + pos +';') + '
').appendTo(placeholder); + if (options.legend.backgroundOpacity != 0.0) { + // put in the transparent background + // separately to avoid blended labels and + // label boxes + var c = options.legend.backgroundColor; + if (c == null) { + c = options.grid.backgroundColor; + if (c && typeof c == "string") + c = $.color.parse(c); + else + c = $.color.extract(legend, 'background-color'); + c.a = 1; + c = c.toString(); + } + var div = legend.children(); + $('
').prependTo(legend).css('opacity', options.legend.backgroundOpacity); + } + } + } + + + // interactive features + + var highlights = [], + redrawTimeout = null; + + // returns the data item the mouse is over, or null if none is found + function findNearbyItem(mouseX, mouseY, seriesFilter) { + var maxDistance = options.grid.mouseActiveRadius, + smallestDistance = maxDistance * maxDistance + 1, + item = null, foundPoint = false, i, j; + + for (i = series.length - 1; i >= 0; --i) { + if (!seriesFilter(series[i])) + continue; + + var s = series[i], + axisx = s.xaxis, + axisy = s.yaxis, + points = s.datapoints.points, + ps = s.datapoints.pointsize, + mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster + my = axisy.c2p(mouseY), + maxx = maxDistance / axisx.scale, + maxy = maxDistance / axisy.scale; + + // with inverse transforms, we can't use the maxx/maxy + // optimization, sadly + if (axisx.options.inverseTransform) + maxx = Number.MAX_VALUE; + if (axisy.options.inverseTransform) + maxy = Number.MAX_VALUE; + + if (s.lines.show || s.points.show) { + for (j = 0; j < points.length; j += ps) { + var x = points[j], y = points[j + 1]; + if (x == null) + continue; + + // For points and lines, the cursor must be within a + // certain distance to the data point + if (x - mx > maxx || x - mx < -maxx || + y - my > maxy || y - my < -maxy) + continue; + + // We have to calculate distances in pixels, not in + // data units, because the scales of the axes may be different + var dx = Math.abs(axisx.p2c(x) - mouseX), + dy = Math.abs(axisy.p2c(y) - mouseY), + dist = dx * dx + dy * dy; // we save the sqrt + + // use <= to ensure last point takes precedence + // (last generally means on top of) + if (dist < smallestDistance) { + smallestDistance = dist; + item = [i, j / ps]; + } + } + } + + if (s.bars.show && !item) { // no other point can be nearby + var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2, + barRight = barLeft + s.bars.barWidth; + + for (j = 0; j < points.length; j += ps) { + var x = points[j], y = points[j + 1], b = points[j + 2]; + if (x == null) + continue; + + // for a bar graph, the cursor must be inside the bar + if (series[i].bars.horizontal ? + (mx <= Math.max(b, x) && mx >= Math.min(b, x) && + my >= y + barLeft && my <= y + barRight) : + (mx >= x + barLeft && mx <= x + barRight && + my >= Math.min(b, y) && my <= Math.max(b, y))) + item = [i, j / ps]; + } + } + } + + if (item) { + i = item[0]; + j = item[1]; + ps = series[i].datapoints.pointsize; + + return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps), + dataIndex: j, + series: series[i], + seriesIndex: i }; + } + + return null; + } + + function onMouseMove(e) { + if (options.grid.hoverable) + triggerClickHoverEvent("plothover", e, + function (s) { return s["hoverable"] != false; }); + } + + function onMouseLeave(e) { + if (options.grid.hoverable) + triggerClickHoverEvent("plothover", e, + function (s) { return false; }); + } + + function onClick(e) { + triggerClickHoverEvent("plotclick", e, + function (s) { return s["clickable"] != false; }); + } + + // trigger click or hover event (they send the same parameters + // so we share their code) + function triggerClickHoverEvent(eventname, event, seriesFilter) { + var offset = eventHolder.offset(), + canvasX = event.pageX - offset.left - plotOffset.left, + canvasY = event.pageY - offset.top - plotOffset.top, + pos = canvasToAxisCoords({ left: canvasX, top: canvasY }); + + pos.pageX = event.pageX; + pos.pageY = event.pageY; + + var item = findNearbyItem(canvasX, canvasY, seriesFilter); + + if (item) { + // fill in mouse pos for any listeners out there + item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left); + item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top); + } + + if (options.grid.autoHighlight) { + // clear auto-highlights + for (var i = 0; i < highlights.length; ++i) { + var h = highlights[i]; + if (h.auto == eventname && + !(item && h.series == item.series && + h.point[0] == item.datapoint[0] && + h.point[1] == item.datapoint[1])) + unhighlight(h.series, h.point); + } + + if (item) + highlight(item.series, item.datapoint, eventname); + } + + event.type = eventname; + placeholder.trigger(event, [ pos, item ]); + } + + function triggerRedrawOverlay() { + if (!redrawTimeout) + redrawTimeout = setTimeout(drawOverlay, 30); + } + + function drawOverlay() { + redrawTimeout = null; + + // draw highlights + octx.save(); + octx.clearRect(0, 0, canvasWidth, canvasHeight); + octx.translate(plotOffset.left, plotOffset.top); + + var i, hi; + for (i = 0; i < highlights.length; ++i) { + hi = highlights[i]; + + if (hi.series.bars.show) + drawBarHighlight(hi.series, hi.point); + else + drawPointHighlight(hi.series, hi.point); + } + octx.restore(); + + executeHooks(hooks.drawOverlay, [octx]); + } + + function highlight(s, point, auto) { + if (typeof s == "number") + s = series[s]; + + if (typeof point == "number") { + var ps = s.datapoints.pointsize; + point = s.datapoints.points.slice(ps * point, ps * (point + 1)); + } + + var i = indexOfHighlight(s, point); + if (i == -1) { + highlights.push({ series: s, point: point, auto: auto }); + + triggerRedrawOverlay(); + } + else if (!auto) + highlights[i].auto = false; + } + + function unhighlight(s, point) { + if (s == null && point == null) { + highlights = []; + triggerRedrawOverlay(); + } + + if (typeof s == "number") + s = series[s]; + + if (typeof point == "number") + point = s.data[point]; + + var i = indexOfHighlight(s, point); + if (i != -1) { + highlights.splice(i, 1); + + triggerRedrawOverlay(); + } + } + + function indexOfHighlight(s, p) { + for (var i = 0; i < highlights.length; ++i) { + var h = highlights[i]; + if (h.series == s && h.point[0] == p[0] + && h.point[1] == p[1]) + return i; + } + return -1; + } + + function drawPointHighlight(series, point) { + var x = point[0], y = point[1], + axisx = series.xaxis, axisy = series.yaxis; + + if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) + return; + + var pointRadius = series.points.radius + series.points.lineWidth / 2; + octx.lineWidth = pointRadius; + octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var radius = 1.5 * pointRadius, + x = axisx.p2c(x), + y = axisy.p2c(y); + + octx.beginPath(); + if (series.points.symbol == "circle") + octx.arc(x, y, radius, 0, 2 * Math.PI, false); + else + series.points.symbol(octx, x, y, radius, false); + octx.closePath(); + octx.stroke(); + } + + function drawBarHighlight(series, point) { + octx.lineWidth = series.bars.lineWidth; + octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; + drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, + 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); + } + + function getColorOrGradient(spec, bottom, top, defaultColor) { + if (typeof spec == "string") + return spec; + else { + // assume this is a gradient spec; IE currently only + // supports a simple vertical gradient properly, so that's + // what we support too + var gradient = ctx.createLinearGradient(0, top, 0, bottom); + + for (var i = 0, l = spec.colors.length; i < l; ++i) { + var c = spec.colors[i]; + if (typeof c != "string") { + var co = $.color.parse(defaultColor); + if (c.brightness != null) + co = co.scale('rgb', c.brightness) + if (c.opacity != null) + co.a *= c.opacity; + c = co.toString(); + } + gradient.addColorStop(i / (l - 1), c); + } + + return gradient; + } + } + } + + $.plot = function(placeholder, data, options) { + //var t0 = new Date(); + //console.time("chart creation"); + var plot = new Plot($(placeholder), data, options, $.plot.plugins); + //console.timeEnd("chart creation"); + //(window.console ? console.log : alert)("time used (msecs): " + ((new Date()).getTime() - t0.getTime())); + return plot; + }; + + $.plot.version = "0.7"; + + $.plot.plugins = []; + + // returns a string with the date d formatted according to fmt + $.plot.formatDate = function(d, fmt, monthNames) { + var leftPad = function(n) { + n = "" + n; + return n.length == 1 ? "0" + n : n; + }; + + var r = []; + var escape = false, padNext = false; + var hours = d.getUTCHours(); + var isAM = hours < 12; + if (monthNames == null) + monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + if (fmt.search(/%p|%P/) != -1) { + if (hours > 12) { + hours = hours - 12; + } else if (hours == 0) { + hours = 12; + } + } + for (var i = 0; i < fmt.length; ++i) { + var c = fmt.charAt(i); + + if (escape) { + switch (c) { + case 'h': c = "" + hours; break; + case 'H': c = leftPad(hours); break; + case 'M': c = leftPad(d.getUTCMinutes()); break; + case 'S': c = leftPad(d.getUTCSeconds()); break; + case 'd': c = "" + d.getUTCDate(); break; + case 'm': c = "" + (d.getUTCMonth() + 1); break; + case 'y': c = "" + d.getUTCFullYear(); break; + case 'b': c = "" + monthNames[d.getUTCMonth()]; break; + case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break; + case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break; + case '0': c = ""; padNext = true; break; + } + if (c && padNext) { + c = leftPad(c); + padNext = false; + } + r.push(c); + if (!padNext) + escape = false; + } + else { + if (c == "%") + escape = true; + else + r.push(c); + } + } + return r.join(""); + }; + + // round to nearby lower multiple of base + function floorInBase(n, base) { + return base * Math.floor(n / base); + } + +})(jQuery); \ No newline at end of file diff --git a/vendors/flot.orderbars/examples/js/flot/stack.js b/vendors/flot.orderbars/examples/js/flot/stack.js new file mode 100644 index 0000000..81ccc46 --- /dev/null +++ b/vendors/flot.orderbars/examples/js/flot/stack.js @@ -0,0 +1,188 @@ +/* Flot plugin for stacking data sets rather than overlaying them. + + Copyright (c) 2007-2012 IOLA and Ole Laursen. + Licensed under the MIT license. + + The plugin assumes the data is sorted on x (or y if stacking horizontally). + For line charts, it is assumed that if a line has an undefined gap (from a + null point), then the line above it should have the same gap - insert zeros + instead of "null" if you want another behaviour. This also holds for the start + and end of the chart. Note that stacking a mix of positive and negative values + in most instances doesn't make sense (so it looks weird). + + Two or more series are stacked when their "stack" attribute is set to the same + key (which can be any number or string or just "true"). To specify the default + stack, you can set the stack option like this: + + series: { + stack: null or true or key (number/string) + } + + You can also specify it for a single series, like this: + + $.plot( $("#placeholder"), [{ + data: [ ... ], + stack: true + }]) + + The stacking order is determined by the order of the data series in the array + (later series end up on top of the previous). + + Internally, the plugin modifies the datapoints in each series, adding an + offset to the y value. For line series, extra data points are inserted through + interpolation. If there's a second y value, it's also adjusted (e.g for bar + charts or filled areas). + + */ + +(function($) { + var options = { + series: { stack: null } // or number/string + }; + + function init(plot) { + function findMatchingSeries(s, allseries) { + var res = null; + for (var i = 0; i < allseries.length; ++i) { + if (s == allseries[i]) + break; + + if (allseries[i].stack == s.stack) + res = allseries[i]; + } + + return res; + } + + function stackData(plot, s, datapoints) { + if (s.stack == null) + return; + + var other = findMatchingSeries(s, plot.getData()); + if (!other) + return; + + var ps = datapoints.pointsize, + points = datapoints.points, + otherps = other.datapoints.pointsize, + otherpoints = other.datapoints.points, + newpoints = [], + px, py, intery, qx, qy, bottom, + withlines = s.lines.show, + horizontal = s.bars.horizontal, + withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y), + withsteps = withlines && s.lines.steps, + fromgap = true, + keyOffset = horizontal ? 1 : 0, + accumulateOffset = horizontal ? 0 : 1, + i = 0, j = 0, l, m; + + while (true) { + if (i >= points.length) + break; + + l = newpoints.length; + + if (points[i] == null) { + // copy gaps + for (m = 0; m < ps; ++m) + newpoints.push(points[i + m]); + i += ps; + } + else if (j >= otherpoints.length) { + // for lines, we can't use the rest of the points + if (!withlines) { + for (m = 0; m < ps; ++m) + newpoints.push(points[i + m]); + } + i += ps; + } + else if (otherpoints[j] == null) { + // oops, got a gap + for (m = 0; m < ps; ++m) + newpoints.push(null); + fromgap = true; + j += otherps; + } + else { + // cases where we actually got two points + px = points[i + keyOffset]; + py = points[i + accumulateOffset]; + qx = otherpoints[j + keyOffset]; + qy = otherpoints[j + accumulateOffset]; + bottom = 0; + + if (px == qx) { + for (m = 0; m < ps; ++m) + newpoints.push(points[i + m]); + + newpoints[l + accumulateOffset] += qy; + bottom = qy; + + i += ps; + j += otherps; + } + else if (px > qx) { + // we got past point below, might need to + // insert interpolated extra point + if (withlines && i > 0 && points[i - ps] != null) { + intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px); + newpoints.push(qx); + newpoints.push(intery + qy); + for (m = 2; m < ps; ++m) + newpoints.push(points[i + m]); + bottom = qy; + } + + j += otherps; + } + else { // px < qx + if (fromgap && withlines) { + // if we come from a gap, we just skip this point + i += ps; + continue; + } + + for (m = 0; m < ps; ++m) + newpoints.push(points[i + m]); + + // we might be able to interpolate a point below, + // this can give us a better y + if (withlines && j > 0 && otherpoints[j - otherps] != null) + bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx); + + newpoints[l + accumulateOffset] += bottom; + + i += ps; + } + + fromgap = false; + + if (l != newpoints.length && withbottom) + newpoints[l + 2] += bottom; + } + + // maintain the line steps invariant + if (withsteps && l != newpoints.length && l > 0 + && newpoints[l] != null + && newpoints[l] != newpoints[l - ps] + && newpoints[l + 1] != newpoints[l - ps + 1]) { + for (m = 0; m < ps; ++m) + newpoints[l + ps + m] = newpoints[l + m]; + newpoints[l + 1] = newpoints[l - ps + 1]; + } + } + + datapoints.points = newpoints; + } + + plot.hooks.processDatapoints.push(stackData); + } + + $.plot.plugins.push({ + init: init, + options: options, + name: 'stack', + version: '1.2' + }); +})(jQuery); \ No newline at end of file diff --git a/vendors/flot.orderbars/examples/js/main.js b/vendors/flot.orderbars/examples/js/main.js new file mode 100644 index 0000000..0e3de89 --- /dev/null +++ b/vendors/flot.orderbars/examples/js/main.js @@ -0,0 +1,80 @@ +// DATA DEFINITION +function getData() { + var data = []; + + data.push({ + data: [[0, 1], [1, 4], [2, 2]] + }); + + data.push({ + data: [[0, 5], [1, 3], [2, 1]] + }); + + return data; +} + + +// ORDERED & STACKED CHART +var orig_data = getData(); + +// Add order: 0 to the existing bars +for(var i = 0; i)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
t
",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; +return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) +}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("