datejs-rails 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +9 -6
- data/Rakefile +21 -0
- data/app/assets/javascripts/date.js +8 -0
- data/changelog.md +4 -0
- data/datejs-rails.gemspec +13 -0
- data/vendor/assets/javascripts/date/af-ZA.js +195 -0
- data/vendor/assets/javascripts/date/ar-AE.js +195 -0
- data/vendor/assets/javascripts/date/ar-BH.js +195 -0
- data/vendor/assets/javascripts/date/ar-DZ.js +195 -0
- data/vendor/assets/javascripts/date/ar-EG.js +195 -0
- data/vendor/assets/javascripts/date/ar-IQ.js +195 -0
- data/vendor/assets/javascripts/date/ar-JO.js +195 -0
- data/vendor/assets/javascripts/date/ar-KW.js +195 -0
- data/vendor/assets/javascripts/date/ar-LB.js +195 -0
- data/vendor/assets/javascripts/date/ar-LY.js +195 -0
- data/vendor/assets/javascripts/date/ar-MA.js +195 -0
- data/vendor/assets/javascripts/date/ar-OM.js +195 -0
- data/vendor/assets/javascripts/date/ar-QA.js +195 -0
- data/vendor/assets/javascripts/date/ar-SA.js +195 -0
- data/vendor/assets/javascripts/date/ar-SY.js +195 -0
- data/vendor/assets/javascripts/date/ar-TN.js +195 -0
- data/vendor/assets/javascripts/date/ar-YE.js +195 -0
- data/vendor/assets/javascripts/date/az-Cyrl-AZ.js +195 -0
- data/vendor/assets/javascripts/date/az-Latn-AZ.js +195 -0
- data/vendor/assets/javascripts/date/be-BY.js +195 -0
- data/vendor/assets/javascripts/date/bg-BG.js +195 -0
- data/vendor/assets/javascripts/date/bs-Latn-BA.js +195 -0
- data/vendor/assets/javascripts/date/ca-ES.js +195 -0
- data/vendor/assets/javascripts/date/core.js +871 -0
- data/vendor/assets/javascripts/date/cs-CZ.js +195 -0
- data/vendor/assets/javascripts/date/cy-GB.js +195 -0
- data/vendor/assets/javascripts/date/da-DK.js +195 -0
- data/vendor/assets/javascripts/date/date.js +21 -0
- data/vendor/assets/javascripts/date/de-AT.js +195 -0
- data/vendor/assets/javascripts/date/de-CH.js +195 -0
- data/vendor/assets/javascripts/date/de-DE.js +195 -0
- data/vendor/assets/javascripts/date/de-LI.js +195 -0
- data/vendor/assets/javascripts/date/de-LU.js +195 -0
- data/vendor/assets/javascripts/date/dv-MV.js +195 -0
- data/vendor/assets/javascripts/date/el-GR.js +195 -0
- data/vendor/assets/javascripts/date/en-029.js +195 -0
- data/vendor/assets/javascripts/date/en-AU.js +195 -0
- data/vendor/assets/javascripts/date/en-BZ.js +195 -0
- data/vendor/assets/javascripts/date/en-CA.js +195 -0
- data/vendor/assets/javascripts/date/en-GB.js +195 -0
- data/vendor/assets/javascripts/date/en-IE.js +195 -0
- data/vendor/assets/javascripts/date/en-JM.js +195 -0
- data/vendor/assets/javascripts/date/en-NZ.js +195 -0
- data/vendor/assets/javascripts/date/en-PH.js +195 -0
- data/vendor/assets/javascripts/date/en-TT.js +195 -0
- data/vendor/assets/javascripts/date/en-US.js +195 -0
- data/vendor/assets/javascripts/date/en-ZA.js +195 -0
- data/vendor/assets/javascripts/date/en-ZW.js +195 -0
- data/vendor/assets/javascripts/date/es-AR.js +195 -0
- data/vendor/assets/javascripts/date/es-BO.js +195 -0
- data/vendor/assets/javascripts/date/es-CL.js +195 -0
- data/vendor/assets/javascripts/date/es-CO.js +195 -0
- data/vendor/assets/javascripts/date/es-CR.js +195 -0
- data/vendor/assets/javascripts/date/es-DO.js +195 -0
- data/vendor/assets/javascripts/date/es-EC.js +195 -0
- data/vendor/assets/javascripts/date/es-ES.js +195 -0
- data/vendor/assets/javascripts/date/es-GT.js +195 -0
- data/vendor/assets/javascripts/date/es-HN.js +195 -0
- data/vendor/assets/javascripts/date/es-MX.js +195 -0
- data/vendor/assets/javascripts/date/es-NI.js +195 -0
- data/vendor/assets/javascripts/date/es-PA.js +195 -0
- data/vendor/assets/javascripts/date/es-PE.js +195 -0
- data/vendor/assets/javascripts/date/es-PR.js +195 -0
- data/vendor/assets/javascripts/date/es-PY.js +195 -0
- data/vendor/assets/javascripts/date/es-SV.js +195 -0
- data/vendor/assets/javascripts/date/es-UY.js +195 -0
- data/vendor/assets/javascripts/date/es-VE.js +195 -0
- data/vendor/assets/javascripts/date/et-EE.js +195 -0
- data/vendor/assets/javascripts/date/eu-ES.js +195 -0
- data/vendor/assets/javascripts/{datejs-extras.js → date/extras.js} +1 -1
- data/vendor/assets/javascripts/date/fa-IR.js +195 -0
- data/vendor/assets/javascripts/date/fi-FI.js +195 -0
- data/vendor/assets/javascripts/date/fo-FO.js +195 -0
- data/vendor/assets/javascripts/date/fr-BE.js +195 -0
- data/vendor/assets/javascripts/date/fr-CA.js +195 -0
- data/vendor/assets/javascripts/date/fr-CH.js +195 -0
- data/vendor/assets/javascripts/date/fr-FR.js +195 -0
- data/vendor/assets/javascripts/date/fr-LU.js +195 -0
- data/vendor/assets/javascripts/date/fr-MC.js +195 -0
- data/vendor/assets/javascripts/date/gl-ES.js +195 -0
- data/vendor/assets/javascripts/date/gu-IN.js +195 -0
- data/vendor/assets/javascripts/date/he-IL.js +195 -0
- data/vendor/assets/javascripts/date/hi-IN.js +195 -0
- data/vendor/assets/javascripts/date/hr-BA.js +195 -0
- data/vendor/assets/javascripts/date/hr-HR.js +195 -0
- data/vendor/assets/javascripts/date/hu-HU.js +195 -0
- data/vendor/assets/javascripts/date/hy-AM.js +195 -0
- data/vendor/assets/javascripts/date/id-ID.js +195 -0
- data/vendor/assets/javascripts/date/is-IS.js +195 -0
- data/vendor/assets/javascripts/date/it-CH.js +195 -0
- data/vendor/assets/javascripts/date/it-IT.js +195 -0
- data/vendor/assets/javascripts/date/ja-JP.js +195 -0
- data/vendor/assets/javascripts/date/ka-GE.js +195 -0
- data/vendor/assets/javascripts/date/kk-KZ.js +195 -0
- data/vendor/assets/javascripts/date/kn-IN.js +195 -0
- data/vendor/assets/javascripts/date/ko-KR.js +195 -0
- data/vendor/assets/javascripts/date/kok-IN.js +195 -0
- data/vendor/assets/javascripts/date/ky-KG.js +195 -0
- data/vendor/assets/javascripts/date/lt-LT.js +195 -0
- data/vendor/assets/javascripts/date/lv-LV.js +195 -0
- data/vendor/assets/javascripts/date/mi-NZ.js +195 -0
- data/vendor/assets/javascripts/date/mk-MK.js +195 -0
- data/vendor/assets/javascripts/date/mn-MN.js +195 -0
- data/vendor/assets/javascripts/date/mr-IN.js +195 -0
- data/vendor/assets/javascripts/date/ms-BN.js +195 -0
- data/vendor/assets/javascripts/date/ms-MY.js +195 -0
- data/vendor/assets/javascripts/date/mt-MT.js +195 -0
- data/vendor/assets/javascripts/date/nb-NO.js +195 -0
- data/vendor/assets/javascripts/date/nl-BE.js +195 -0
- data/vendor/assets/javascripts/date/nl-NL.js +195 -0
- data/vendor/assets/javascripts/date/nn-NO.js +195 -0
- data/vendor/assets/javascripts/date/ns-ZA.js +195 -0
- data/vendor/assets/javascripts/date/pa-IN.js +195 -0
- data/vendor/assets/javascripts/date/parser.js +1170 -0
- data/vendor/assets/javascripts/date/pl-PL.js +195 -0
- data/vendor/assets/javascripts/date/pt-BR.js +195 -0
- data/vendor/assets/javascripts/date/pt-PT.js +195 -0
- data/vendor/assets/javascripts/date/quz-BO.js +195 -0
- data/vendor/assets/javascripts/date/quz-EC.js +195 -0
- data/vendor/assets/javascripts/date/quz-PE.js +195 -0
- data/vendor/assets/javascripts/date/ro-RO.js +195 -0
- data/vendor/assets/javascripts/date/ru-RU.js +195 -0
- data/vendor/assets/javascripts/date/sa-IN.js +195 -0
- data/vendor/assets/javascripts/date/se-FI.js +195 -0
- data/vendor/assets/javascripts/date/se-NO.js +195 -0
- data/vendor/assets/javascripts/date/se-SE.js +195 -0
- data/vendor/assets/javascripts/date/sk-SK.js +195 -0
- data/vendor/assets/javascripts/date/sl-SI.js +195 -0
- data/vendor/assets/javascripts/date/sma-NO.js +195 -0
- data/vendor/assets/javascripts/date/sma-SE.js +195 -0
- data/vendor/assets/javascripts/date/smj-NO.js +195 -0
- data/vendor/assets/javascripts/date/smj-SE.js +195 -0
- data/vendor/assets/javascripts/date/smn-FI.js +195 -0
- data/vendor/assets/javascripts/date/sms-FI.js +195 -0
- data/vendor/assets/javascripts/date/sq-AL.js +195 -0
- data/vendor/assets/javascripts/date/sr-Cyrl-BA.js +195 -0
- data/vendor/assets/javascripts/date/sr-Cyrl-CS.js +195 -0
- data/vendor/assets/javascripts/date/sr-Latn-BA.js +195 -0
- data/vendor/assets/javascripts/date/sr-Latn-CS.js +195 -0
- data/vendor/assets/javascripts/date/sugarpak.js +476 -0
- data/vendor/assets/javascripts/date/sv-FI.js +195 -0
- data/vendor/assets/javascripts/date/sv-SE.js +195 -0
- data/vendor/assets/javascripts/date/sw-KE.js +195 -0
- data/vendor/assets/javascripts/date/syr-SY.js +195 -0
- data/vendor/assets/javascripts/date/ta-IN.js +195 -0
- data/vendor/assets/javascripts/date/te-IN.js +195 -0
- data/vendor/assets/javascripts/date/th-TH.js +195 -0
- data/vendor/assets/javascripts/date/time.js +269 -0
- data/vendor/assets/javascripts/date/tn-ZA.js +195 -0
- data/vendor/assets/javascripts/date/tr-TR.js +195 -0
- data/vendor/assets/javascripts/date/tt-RU.js +195 -0
- data/vendor/assets/javascripts/date/uk-UA.js +195 -0
- data/vendor/assets/javascripts/date/ur-PK.js +195 -0
- data/vendor/assets/javascripts/date/uz-Cyrl-UZ.js +195 -0
- data/vendor/assets/javascripts/date/uz-Latn-UZ.js +195 -0
- data/vendor/assets/javascripts/date/vi-VN.js +195 -0
- data/vendor/assets/javascripts/date/xh-ZA.js +195 -0
- data/vendor/assets/javascripts/date/zh-CN.js +195 -0
- data/vendor/assets/javascripts/date/zh-HK.js +195 -0
- data/vendor/assets/javascripts/date/zh-MO.js +195 -0
- data/vendor/assets/javascripts/date/zh-SG.js +195 -0
- data/vendor/assets/javascripts/date/zh-TW.js +195 -0
- data/vendor/assets/javascripts/date/zu-ZA.js +195 -0
- metadata +221 -188
- data/vendor/assets/javascripts/date-af-ZA.js +0 -104
- data/vendor/assets/javascripts/date-ar-AE.js +0 -104
- data/vendor/assets/javascripts/date-ar-BH.js +0 -104
- data/vendor/assets/javascripts/date-ar-DZ.js +0 -104
- data/vendor/assets/javascripts/date-ar-EG.js +0 -104
- data/vendor/assets/javascripts/date-ar-IQ.js +0 -104
- data/vendor/assets/javascripts/date-ar-JO.js +0 -104
- data/vendor/assets/javascripts/date-ar-KW.js +0 -104
- data/vendor/assets/javascripts/date-ar-LB.js +0 -104
- data/vendor/assets/javascripts/date-ar-LY.js +0 -104
- data/vendor/assets/javascripts/date-ar-MA.js +0 -104
- data/vendor/assets/javascripts/date-ar-OM.js +0 -104
- data/vendor/assets/javascripts/date-ar-QA.js +0 -104
- data/vendor/assets/javascripts/date-ar-SA.js +0 -104
- data/vendor/assets/javascripts/date-ar-SY.js +0 -104
- data/vendor/assets/javascripts/date-ar-TN.js +0 -104
- data/vendor/assets/javascripts/date-ar-YE.js +0 -104
- data/vendor/assets/javascripts/date-az-Cyrl-AZ.js +0 -104
- data/vendor/assets/javascripts/date-az-Latn-AZ.js +0 -104
- data/vendor/assets/javascripts/date-be-BY.js +0 -104
- data/vendor/assets/javascripts/date-bg-BG.js +0 -104
- data/vendor/assets/javascripts/date-bs-Latn-BA.js +0 -104
- data/vendor/assets/javascripts/date-ca-ES.js +0 -104
- data/vendor/assets/javascripts/date-cs-CZ.js +0 -104
- data/vendor/assets/javascripts/date-cy-GB.js +0 -104
- data/vendor/assets/javascripts/date-da-DK.js +0 -104
- data/vendor/assets/javascripts/date-de-AT.js +0 -104
- data/vendor/assets/javascripts/date-de-CH.js +0 -104
- data/vendor/assets/javascripts/date-de-DE.js +0 -104
- data/vendor/assets/javascripts/date-de-LI.js +0 -104
- data/vendor/assets/javascripts/date-de-LU.js +0 -104
- data/vendor/assets/javascripts/date-dv-MV.js +0 -104
- data/vendor/assets/javascripts/date-el-GR.js +0 -104
- data/vendor/assets/javascripts/date-en-029.js +0 -104
- data/vendor/assets/javascripts/date-en-AU.js +0 -104
- data/vendor/assets/javascripts/date-en-BZ.js +0 -104
- data/vendor/assets/javascripts/date-en-CA.js +0 -104
- data/vendor/assets/javascripts/date-en-GB.js +0 -104
- data/vendor/assets/javascripts/date-en-IE.js +0 -104
- data/vendor/assets/javascripts/date-en-JM.js +0 -104
- data/vendor/assets/javascripts/date-en-NZ.js +0 -104
- data/vendor/assets/javascripts/date-en-PH.js +0 -104
- data/vendor/assets/javascripts/date-en-TT.js +0 -104
- data/vendor/assets/javascripts/date-en-US.js +0 -104
- data/vendor/assets/javascripts/date-en-ZA.js +0 -104
- data/vendor/assets/javascripts/date-en-ZW.js +0 -104
- data/vendor/assets/javascripts/date-es-AR.js +0 -104
- data/vendor/assets/javascripts/date-es-BO.js +0 -104
- data/vendor/assets/javascripts/date-es-CL.js +0 -104
- data/vendor/assets/javascripts/date-es-CO.js +0 -104
- data/vendor/assets/javascripts/date-es-CR.js +0 -104
- data/vendor/assets/javascripts/date-es-DO.js +0 -104
- data/vendor/assets/javascripts/date-es-EC.js +0 -104
- data/vendor/assets/javascripts/date-es-ES.js +0 -104
- data/vendor/assets/javascripts/date-es-GT.js +0 -104
- data/vendor/assets/javascripts/date-es-HN.js +0 -104
- data/vendor/assets/javascripts/date-es-MX.js +0 -104
- data/vendor/assets/javascripts/date-es-NI.js +0 -104
- data/vendor/assets/javascripts/date-es-PA.js +0 -104
- data/vendor/assets/javascripts/date-es-PE.js +0 -104
- data/vendor/assets/javascripts/date-es-PR.js +0 -104
- data/vendor/assets/javascripts/date-es-PY.js +0 -104
- data/vendor/assets/javascripts/date-es-SV.js +0 -104
- data/vendor/assets/javascripts/date-es-UY.js +0 -104
- data/vendor/assets/javascripts/date-es-VE.js +0 -104
- data/vendor/assets/javascripts/date-et-EE.js +0 -104
- data/vendor/assets/javascripts/date-eu-ES.js +0 -104
- data/vendor/assets/javascripts/date-fa-IR.js +0 -104
- data/vendor/assets/javascripts/date-fi-FI.js +0 -104
- data/vendor/assets/javascripts/date-fo-FO.js +0 -104
- data/vendor/assets/javascripts/date-fr-BE.js +0 -104
- data/vendor/assets/javascripts/date-fr-CA.js +0 -104
- data/vendor/assets/javascripts/date-fr-CH.js +0 -104
- data/vendor/assets/javascripts/date-fr-FR.js +0 -104
- data/vendor/assets/javascripts/date-fr-LU.js +0 -104
- data/vendor/assets/javascripts/date-fr-MC.js +0 -104
- data/vendor/assets/javascripts/date-gl-ES.js +0 -104
- data/vendor/assets/javascripts/date-gu-IN.js +0 -104
- data/vendor/assets/javascripts/date-he-IL.js +0 -104
- data/vendor/assets/javascripts/date-hi-IN.js +0 -104
- data/vendor/assets/javascripts/date-hr-BA.js +0 -104
- data/vendor/assets/javascripts/date-hr-HR.js +0 -104
- data/vendor/assets/javascripts/date-hu-HU.js +0 -104
- data/vendor/assets/javascripts/date-hy-AM.js +0 -104
- data/vendor/assets/javascripts/date-id-ID.js +0 -104
- data/vendor/assets/javascripts/date-is-IS.js +0 -104
- data/vendor/assets/javascripts/date-it-CH.js +0 -104
- data/vendor/assets/javascripts/date-it-IT.js +0 -104
- data/vendor/assets/javascripts/date-ja-JP.js +0 -104
- data/vendor/assets/javascripts/date-ka-GE.js +0 -104
- data/vendor/assets/javascripts/date-kk-KZ.js +0 -104
- data/vendor/assets/javascripts/date-kn-IN.js +0 -104
- data/vendor/assets/javascripts/date-ko-KR.js +0 -104
- data/vendor/assets/javascripts/date-kok-IN.js +0 -104
- data/vendor/assets/javascripts/date-ky-KG.js +0 -104
- data/vendor/assets/javascripts/date-lt-LT.js +0 -104
- data/vendor/assets/javascripts/date-lv-LV.js +0 -104
- data/vendor/assets/javascripts/date-mi-NZ.js +0 -104
- data/vendor/assets/javascripts/date-mk-MK.js +0 -104
- data/vendor/assets/javascripts/date-mn-MN.js +0 -104
- data/vendor/assets/javascripts/date-mr-IN.js +0 -104
- data/vendor/assets/javascripts/date-ms-BN.js +0 -104
- data/vendor/assets/javascripts/date-ms-MY.js +0 -104
- data/vendor/assets/javascripts/date-mt-MT.js +0 -104
- data/vendor/assets/javascripts/date-nb-NO.js +0 -104
- data/vendor/assets/javascripts/date-nl-BE.js +0 -104
- data/vendor/assets/javascripts/date-nl-NL.js +0 -104
- data/vendor/assets/javascripts/date-nn-NO.js +0 -104
- data/vendor/assets/javascripts/date-ns-ZA.js +0 -104
- data/vendor/assets/javascripts/date-pa-IN.js +0 -104
- data/vendor/assets/javascripts/date-pl-PL.js +0 -104
- data/vendor/assets/javascripts/date-pt-BR.js +0 -104
- data/vendor/assets/javascripts/date-pt-PT.js +0 -104
- data/vendor/assets/javascripts/date-quz-BO.js +0 -104
- data/vendor/assets/javascripts/date-quz-EC.js +0 -104
- data/vendor/assets/javascripts/date-quz-PE.js +0 -104
- data/vendor/assets/javascripts/date-ro-RO.js +0 -104
- data/vendor/assets/javascripts/date-ru-RU.js +0 -104
- data/vendor/assets/javascripts/date-sa-IN.js +0 -104
- data/vendor/assets/javascripts/date-se-FI.js +0 -104
- data/vendor/assets/javascripts/date-se-NO.js +0 -104
- data/vendor/assets/javascripts/date-se-SE.js +0 -104
- data/vendor/assets/javascripts/date-sk-SK.js +0 -104
- data/vendor/assets/javascripts/date-sl-SI.js +0 -104
- data/vendor/assets/javascripts/date-sma-NO.js +0 -104
- data/vendor/assets/javascripts/date-sma-SE.js +0 -104
- data/vendor/assets/javascripts/date-smj-NO.js +0 -104
- data/vendor/assets/javascripts/date-smj-SE.js +0 -104
- data/vendor/assets/javascripts/date-smn-FI.js +0 -104
- data/vendor/assets/javascripts/date-sms-FI.js +0 -104
- data/vendor/assets/javascripts/date-sq-AL.js +0 -104
- data/vendor/assets/javascripts/date-sr-Cyrl-BA.js +0 -104
- data/vendor/assets/javascripts/date-sr-Cyrl-CS.js +0 -104
- data/vendor/assets/javascripts/date-sr-Latn-BA.js +0 -104
- data/vendor/assets/javascripts/date-sr-Latn-CS.js +0 -104
- data/vendor/assets/javascripts/date-sv-FI.js +0 -104
- data/vendor/assets/javascripts/date-sv-SE.js +0 -104
- data/vendor/assets/javascripts/date-sw-KE.js +0 -104
- data/vendor/assets/javascripts/date-syr-SY.js +0 -104
- data/vendor/assets/javascripts/date-ta-IN.js +0 -104
- data/vendor/assets/javascripts/date-te-IN.js +0 -104
- data/vendor/assets/javascripts/date-th-TH.js +0 -104
- data/vendor/assets/javascripts/date-tn-ZA.js +0 -104
- data/vendor/assets/javascripts/date-tr-TR.js +0 -104
- data/vendor/assets/javascripts/date-tt-RU.js +0 -104
- data/vendor/assets/javascripts/date-uk-UA.js +0 -104
- data/vendor/assets/javascripts/date-ur-PK.js +0 -104
- data/vendor/assets/javascripts/date-uz-Cyrl-UZ.js +0 -104
- data/vendor/assets/javascripts/date-uz-Latn-UZ.js +0 -104
- data/vendor/assets/javascripts/date-vi-VN.js +0 -104
- data/vendor/assets/javascripts/date-xh-ZA.js +0 -104
- data/vendor/assets/javascripts/date-zh-CN.js +0 -104
- data/vendor/assets/javascripts/date-zh-HK.js +0 -104
- data/vendor/assets/javascripts/date-zh-MO.js +0 -104
- data/vendor/assets/javascripts/date-zh-SG.js +0 -104
- data/vendor/assets/javascripts/date-zh-TW.js +0 -104
- data/vendor/assets/javascripts/date-zu-ZA.js +0 -104
- data/vendor/assets/javascripts/date.js +0 -104
@@ -0,0 +1,871 @@
|
|
1
|
+
/**
|
2
|
+
* @version: 1.0 Alpha-1
|
3
|
+
* @author: Coolite Inc. http://www.coolite.com/
|
4
|
+
* @date: 2008-04-13
|
5
|
+
* @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
|
6
|
+
* @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
|
7
|
+
* @website: http://www.datejs.com/
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function () {
|
11
|
+
var $D = Date,
|
12
|
+
$P = $D.prototype,
|
13
|
+
$C = $D.CultureInfo,
|
14
|
+
p = function (s, l) {
|
15
|
+
if (!l) {
|
16
|
+
l = 2;
|
17
|
+
}
|
18
|
+
return ("000" + s).slice(l * -1);
|
19
|
+
};
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day.
|
23
|
+
* @param {Boolean} .clone() this date instance before clearing Time
|
24
|
+
* @return {Date} this
|
25
|
+
*/
|
26
|
+
$P.clearTime = function () {
|
27
|
+
this.setHours(0);
|
28
|
+
this.setMinutes(0);
|
29
|
+
this.setSeconds(0);
|
30
|
+
this.setMilliseconds(0);
|
31
|
+
return this;
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Resets the time of this Date object to the current time ('now').
|
36
|
+
* @return {Date} this
|
37
|
+
*/
|
38
|
+
$P.setTimeToNow = function () {
|
39
|
+
var n = new Date();
|
40
|
+
this.setHours(n.getHours());
|
41
|
+
this.setMinutes(n.getMinutes());
|
42
|
+
this.setSeconds(n.getSeconds());
|
43
|
+
this.setMilliseconds(n.getMilliseconds());
|
44
|
+
return this;
|
45
|
+
};
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM).
|
49
|
+
* @return {Date} The current date.
|
50
|
+
*/
|
51
|
+
$D.today = function () {
|
52
|
+
return new Date().clearTime();
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Compares the first date to the second date and returns an number indication of their relative values.
|
57
|
+
* @param {Date} First Date object to compare [Required].
|
58
|
+
* @param {Date} Second Date object to compare to [Required].
|
59
|
+
* @return {Number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2.
|
60
|
+
*/
|
61
|
+
$D.compare = function (date1, date2) {
|
62
|
+
if (isNaN(date1) || isNaN(date2)) {
|
63
|
+
throw new Error(date1 + " - " + date2);
|
64
|
+
} else if (date1 instanceof Date && date2 instanceof Date) {
|
65
|
+
return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0;
|
66
|
+
} else {
|
67
|
+
throw new TypeError(date1 + " - " + date2);
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Compares the first Date object to the second Date object and returns true if they are equal.
|
73
|
+
* @param {Date} First Date object to compare [Required]
|
74
|
+
* @param {Date} Second Date object to compare to [Required]
|
75
|
+
* @return {Boolean} true if dates are equal. false if they are not equal.
|
76
|
+
*/
|
77
|
+
$D.equals = function (date1, date2) {
|
78
|
+
return (date1.compareTo(date2) === 0);
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char).
|
83
|
+
* @param {String} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we").
|
84
|
+
* @return {Number} The day number
|
85
|
+
*/
|
86
|
+
$D.getDayNumberFromName = function (name) {
|
87
|
+
var n = $C.dayNames, m = $C.abbreviatedDayNames, o = $C.shortestDayNames, s = name.toLowerCase();
|
88
|
+
for (var i = 0; i < n.length; i++) {
|
89
|
+
if (n[i].toLowerCase() == s || m[i].toLowerCase() == s || o[i].toLowerCase() == s) {
|
90
|
+
return i;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return -1;
|
94
|
+
};
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName.
|
98
|
+
* @param {String} The name of the month (eg. "February, "Feb", "october", "oct").
|
99
|
+
* @return {Number} The day number
|
100
|
+
*/
|
101
|
+
$D.getMonthNumberFromName = function (name) {
|
102
|
+
var n = $C.monthNames, m = $C.abbreviatedMonthNames, s = name.toLowerCase();
|
103
|
+
for (var i = 0; i < n.length; i++) {
|
104
|
+
if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) {
|
105
|
+
return i;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return -1;
|
109
|
+
};
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Determines if the current date instance is within a LeapYear.
|
113
|
+
* @param {Number} The year.
|
114
|
+
* @return {Boolean} true if date is within a LeapYear, otherwise false.
|
115
|
+
*/
|
116
|
+
$D.isLeapYear = function (year) {
|
117
|
+
return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
|
118
|
+
};
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Gets the number of days in the month, given a year and month value. Automatically corrects for LeapYear.
|
122
|
+
* @param {Number} The year.
|
123
|
+
* @param {Number} The month (0-11).
|
124
|
+
* @return {Number} The number of days in the month.
|
125
|
+
*/
|
126
|
+
$D.getDaysInMonth = function (year, month) {
|
127
|
+
return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
128
|
+
};
|
129
|
+
|
130
|
+
$D.getTimezoneAbbreviation = function (offset) {
|
131
|
+
var z = $C.timezones, p;
|
132
|
+
for (var i = 0; i < z.length; i++) {
|
133
|
+
if (z[i].offset === offset) {
|
134
|
+
return z[i].name;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
return null;
|
138
|
+
};
|
139
|
+
|
140
|
+
$D.getTimezoneOffset = function (name) {
|
141
|
+
var z = $C.timezones, p;
|
142
|
+
for (var i = 0; i < z.length; i++) {
|
143
|
+
if (z[i].name === name.toUpperCase()) {
|
144
|
+
return z[i].offset;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
return null;
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Returns a new Date object that is an exact date and time copy of the original instance.
|
152
|
+
* @return {Date} A new Date instance
|
153
|
+
*/
|
154
|
+
$P.clone = function () {
|
155
|
+
return new Date(this.getTime());
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Compares this instance to a Date object and returns an number indication of their relative values.
|
160
|
+
* @param {Date} Date object to compare [Required]
|
161
|
+
* @return {Number} -1 = this is lessthan date. 0 = values are equal. 1 = this is greaterthan date.
|
162
|
+
*/
|
163
|
+
$P.compareTo = function (date) {
|
164
|
+
return Date.compare(this, date);
|
165
|
+
};
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Compares this instance to another Date object and returns true if they are equal.
|
169
|
+
* @param {Date} Date object to compare. If no date to compare, new Date() [now] is used.
|
170
|
+
* @return {Boolean} true if dates are equal. false if they are not equal.
|
171
|
+
*/
|
172
|
+
$P.equals = function (date) {
|
173
|
+
return Date.equals(this, date || new Date());
|
174
|
+
};
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Determines if this instance is between a range of two dates or equal to either the start or end dates.
|
178
|
+
* @param {Date} Start of range [Required]
|
179
|
+
* @param {Date} End of range [Required]
|
180
|
+
* @return {Boolean} true is this is between or equal to the start and end dates, else false
|
181
|
+
*/
|
182
|
+
$P.between = function (start, end) {
|
183
|
+
return this.getTime() >= start.getTime() && this.getTime() <= end.getTime();
|
184
|
+
};
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Determines if this date occurs after the date to compare to.
|
188
|
+
* @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used.
|
189
|
+
* @return {Boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false.
|
190
|
+
*/
|
191
|
+
$P.isAfter = function (date) {
|
192
|
+
return this.compareTo(date || new Date()) === 1;
|
193
|
+
};
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Determines if this date occurs before the date to compare to.
|
197
|
+
* @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used.
|
198
|
+
* @return {Boolean} true if this date instance is less than the date to compare to (or "now").
|
199
|
+
*/
|
200
|
+
$P.isBefore = function (date) {
|
201
|
+
return (this.compareTo(date || new Date()) === -1);
|
202
|
+
};
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Determines if the current Date instance occurs today.
|
206
|
+
* @return {Boolean} true if this date instance is 'today', otherwise false.
|
207
|
+
*/
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Determines if the current Date instance occurs on the same Date as the supplied 'date'.
|
211
|
+
* If no 'date' to compare to is provided, the current Date instance is compared to 'today'.
|
212
|
+
* @param {date} Date object to compare. If no date to compare, the current Date ("now") is used.
|
213
|
+
* @return {Boolean} true if this Date instance occurs on the same Day as the supplied 'date'.
|
214
|
+
*/
|
215
|
+
$P.isToday = $P.isSameDay = function (date) {
|
216
|
+
return this.clone().clearTime().equals((date || new Date()).clone().clearTime());
|
217
|
+
};
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Adds the specified number of milliseconds to this instance.
|
221
|
+
* @param {Number} The number of milliseconds to add. The number can be positive or negative [Required]
|
222
|
+
* @return {Date} this
|
223
|
+
*/
|
224
|
+
$P.addMilliseconds = function (value) {
|
225
|
+
this.setMilliseconds(this.getMilliseconds() + value * 1);
|
226
|
+
return this;
|
227
|
+
};
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Adds the specified number of seconds to this instance.
|
231
|
+
* @param {Number} The number of seconds to add. The number can be positive or negative [Required]
|
232
|
+
* @return {Date} this
|
233
|
+
*/
|
234
|
+
$P.addSeconds = function (value) {
|
235
|
+
return this.addMilliseconds(value * 1000);
|
236
|
+
};
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Adds the specified number of seconds to this instance.
|
240
|
+
* @param {Number} The number of seconds to add. The number can be positive or negative [Required]
|
241
|
+
* @return {Date} this
|
242
|
+
*/
|
243
|
+
$P.addMinutes = function (value) {
|
244
|
+
return this.addMilliseconds(value * 60000); /* 60*1000 */
|
245
|
+
};
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Adds the specified number of hours to this instance.
|
249
|
+
* @param {Number} The number of hours to add. The number can be positive or negative [Required]
|
250
|
+
* @return {Date} this
|
251
|
+
*/
|
252
|
+
$P.addHours = function (value) {
|
253
|
+
return this.addMilliseconds(value * 3600000); /* 60*60*1000 */
|
254
|
+
};
|
255
|
+
|
256
|
+
/**
|
257
|
+
* Adds the specified number of days to this instance.
|
258
|
+
* @param {Number} The number of days to add. The number can be positive or negative [Required]
|
259
|
+
* @return {Date} this
|
260
|
+
*/
|
261
|
+
$P.addDays = function (value) {
|
262
|
+
this.setDate(this.getDate() + value * 1);
|
263
|
+
return this;
|
264
|
+
};
|
265
|
+
|
266
|
+
/**
|
267
|
+
* Adds the specified number of weeks to this instance.
|
268
|
+
* @param {Number} The number of weeks to add. The number can be positive or negative [Required]
|
269
|
+
* @return {Date} this
|
270
|
+
*/
|
271
|
+
$P.addWeeks = function (value) {
|
272
|
+
return this.addDays(value * 7);
|
273
|
+
};
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Adds the specified number of months to this instance.
|
277
|
+
* @param {Number} The number of months to add. The number can be positive or negative [Required]
|
278
|
+
* @return {Date} this
|
279
|
+
*/
|
280
|
+
$P.addMonths = function (value) {
|
281
|
+
var n = this.getDate();
|
282
|
+
this.setDate(1);
|
283
|
+
this.setMonth(this.getMonth() + value * 1);
|
284
|
+
this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth())));
|
285
|
+
return this;
|
286
|
+
};
|
287
|
+
|
288
|
+
/**
|
289
|
+
* Adds the specified number of years to this instance.
|
290
|
+
* @param {Number} The number of years to add. The number can be positive or negative [Required]
|
291
|
+
* @return {Date} this
|
292
|
+
*/
|
293
|
+
$P.addYears = function (value) {
|
294
|
+
return this.addMonths(value * 12);
|
295
|
+
};
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed.
|
299
|
+
* Example
|
300
|
+
<pre><code>
|
301
|
+
Date.today().add( { days: 1, months: 1 } )
|
302
|
+
|
303
|
+
new Date().add( { years: -1 } )
|
304
|
+
</code></pre>
|
305
|
+
* @param {Object} Configuration object containing attributes (months, days, etc.)
|
306
|
+
* @return {Date} this
|
307
|
+
*/
|
308
|
+
$P.add = function (config) {
|
309
|
+
if (typeof config == "number") {
|
310
|
+
this._orient = config;
|
311
|
+
return this;
|
312
|
+
}
|
313
|
+
|
314
|
+
var x = config;
|
315
|
+
|
316
|
+
if (x.milliseconds) {
|
317
|
+
this.addMilliseconds(x.milliseconds);
|
318
|
+
}
|
319
|
+
if (x.seconds) {
|
320
|
+
this.addSeconds(x.seconds);
|
321
|
+
}
|
322
|
+
if (x.minutes) {
|
323
|
+
this.addMinutes(x.minutes);
|
324
|
+
}
|
325
|
+
if (x.hours) {
|
326
|
+
this.addHours(x.hours);
|
327
|
+
}
|
328
|
+
if (x.weeks) {
|
329
|
+
this.addWeeks(x.weeks);
|
330
|
+
}
|
331
|
+
if (x.months) {
|
332
|
+
this.addMonths(x.months);
|
333
|
+
}
|
334
|
+
if (x.years) {
|
335
|
+
this.addYears(x.years);
|
336
|
+
}
|
337
|
+
if (x.days) {
|
338
|
+
this.addDays(x.days);
|
339
|
+
}
|
340
|
+
return this;
|
341
|
+
};
|
342
|
+
|
343
|
+
var $y, $m, $d;
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Get the week number. Week one (1) is the week which contains the first Thursday of the year. Monday is considered the first day of the week.
|
347
|
+
* This algorithm is a JavaScript port of the work presented by Claus T�ndering at http://www.tondering.dk/claus/cal/node8.html#SECTION00880000000000000000
|
348
|
+
* .getWeek() Algorithm Copyright (c) 2008 Claus Tondering.
|
349
|
+
* The .getWeek() function does NOT convert the date to UTC. The local datetime is used. Please use .getISOWeek() to get the week of the UTC converted date.
|
350
|
+
* @return {Number} 1 to 53
|
351
|
+
*/
|
352
|
+
$P.getWeek = function () {
|
353
|
+
var a, b, c, d, e, f, g, n, s, w;
|
354
|
+
|
355
|
+
$y = (!$y) ? this.getFullYear() : $y;
|
356
|
+
$m = (!$m) ? this.getMonth() + 1 : $m;
|
357
|
+
$d = (!$d) ? this.getDate() : $d;
|
358
|
+
|
359
|
+
if ($m <= 2) {
|
360
|
+
a = $y - 1;
|
361
|
+
b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0);
|
362
|
+
c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0);
|
363
|
+
s = b - c;
|
364
|
+
e = 0;
|
365
|
+
f = $d - 1 + (31 * ($m - 1));
|
366
|
+
} else {
|
367
|
+
a = $y;
|
368
|
+
b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0);
|
369
|
+
c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0);
|
370
|
+
s = b - c;
|
371
|
+
e = s + 1;
|
372
|
+
f = $d + ((153 * ($m - 3) + 2) / 5) + 58 + s;
|
373
|
+
}
|
374
|
+
|
375
|
+
g = (a + b) % 7;
|
376
|
+
d = (f + g - e) % 7;
|
377
|
+
n = (f + 3 - d) | 0;
|
378
|
+
|
379
|
+
if (n < 0) {
|
380
|
+
w = 53 - ((g - s) / 5 | 0);
|
381
|
+
} else if (n > 364 + s) {
|
382
|
+
w = 1;
|
383
|
+
} else {
|
384
|
+
w = (n / 7 | 0) + 1;
|
385
|
+
}
|
386
|
+
|
387
|
+
$y = $m = $d = null;
|
388
|
+
|
389
|
+
return w;
|
390
|
+
};
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week.
|
394
|
+
* The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date.
|
395
|
+
* @return {String} "01" to "53"
|
396
|
+
*/
|
397
|
+
$P.getISOWeek = function () {
|
398
|
+
$y = this.getUTCFullYear();
|
399
|
+
$m = this.getUTCMonth() + 1;
|
400
|
+
$d = this.getUTCDate();
|
401
|
+
return p(this.getWeek());
|
402
|
+
};
|
403
|
+
|
404
|
+
/**
|
405
|
+
* Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year.
|
406
|
+
* @param {Number} A Number (1 to 53) that represents the week of the year.
|
407
|
+
* @return {Date} this
|
408
|
+
*/
|
409
|
+
$P.setWeek = function (n) {
|
410
|
+
return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek());
|
411
|
+
};
|
412
|
+
|
413
|
+
// private
|
414
|
+
var validate = function (n, min, max, name) {
|
415
|
+
if (typeof n == "undefined" || n == null) {
|
416
|
+
return false;
|
417
|
+
} else if (typeof n != "number") {
|
418
|
+
throw new TypeError(n + " is not a Number.");
|
419
|
+
} else if (n < min || n > max) {
|
420
|
+
throw new RangeError(n + " is not a valid value for " + name + ".");
|
421
|
+
}
|
422
|
+
return true;
|
423
|
+
};
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Validates the number is within an acceptable range for milliseconds [0-999].
|
427
|
+
* @param {Number} The number to check if within range.
|
428
|
+
* @return {Boolean} true if within range, otherwise false.
|
429
|
+
*/
|
430
|
+
$D.validateMillisecond = function (value) {
|
431
|
+
return validate(value, 0, 999, "millisecond");
|
432
|
+
};
|
433
|
+
|
434
|
+
/**
|
435
|
+
* Validates the number is within an acceptable range for seconds [0-59].
|
436
|
+
* @param {Number} The number to check if within range.
|
437
|
+
* @return {Boolean} true if within range, otherwise false.
|
438
|
+
*/
|
439
|
+
$D.validateSecond = function (value) {
|
440
|
+
return validate(value, 0, 59, "second");
|
441
|
+
};
|
442
|
+
|
443
|
+
/**
|
444
|
+
* Validates the number is within an acceptable range for minutes [0-59].
|
445
|
+
* @param {Number} The number to check if within range.
|
446
|
+
* @return {Boolean} true if within range, otherwise false.
|
447
|
+
*/
|
448
|
+
$D.validateMinute = function (value) {
|
449
|
+
return validate(value, 0, 59, "minute");
|
450
|
+
};
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Validates the number is within an acceptable range for hours [0-23].
|
454
|
+
* @param {Number} The number to check if within range.
|
455
|
+
* @return {Boolean} true if within range, otherwise false.
|
456
|
+
*/
|
457
|
+
$D.validateHour = function (value) {
|
458
|
+
return validate(value, 0, 23, "hour");
|
459
|
+
};
|
460
|
+
|
461
|
+
/**
|
462
|
+
* Validates the number is within an acceptable range for the days in a month [0-MaxDaysInMonth].
|
463
|
+
* @param {Number} The number to check if within range.
|
464
|
+
* @return {Boolean} true if within range, otherwise false.
|
465
|
+
*/
|
466
|
+
$D.validateDay = function (value, year, month) {
|
467
|
+
return validate(value, 1, $D.getDaysInMonth(year, month), "day");
|
468
|
+
};
|
469
|
+
|
470
|
+
/**
|
471
|
+
* Validates the number is within an acceptable range for months [0-11].
|
472
|
+
* @param {Number} The number to check if within range.
|
473
|
+
* @return {Boolean} true if within range, otherwise false.
|
474
|
+
*/
|
475
|
+
$D.validateMonth = function (value) {
|
476
|
+
return validate(value, 0, 11, "month");
|
477
|
+
};
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Validates the number is within an acceptable range for years.
|
481
|
+
* @param {Number} The number to check if within range.
|
482
|
+
* @return {Boolean} true if within range, otherwise false.
|
483
|
+
*/
|
484
|
+
$D.validateYear = function (value) {
|
485
|
+
return validate(value, 0, 9999, "year");
|
486
|
+
};
|
487
|
+
|
488
|
+
/**
|
489
|
+
* Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object.
|
490
|
+
* Example
|
491
|
+
<pre><code>
|
492
|
+
Date.today().set( { day: 20, month: 1 } )
|
493
|
+
|
494
|
+
new Date().set( { millisecond: 0 } )
|
495
|
+
</code></pre>
|
496
|
+
*
|
497
|
+
* @param {Object} Configuration object containing attributes (month, day, etc.)
|
498
|
+
* @return {Date} this
|
499
|
+
*/
|
500
|
+
$P.set = function (config) {
|
501
|
+
if ($D.validateMillisecond(config.millisecond)) {
|
502
|
+
this.addMilliseconds(config.millisecond - this.getMilliseconds());
|
503
|
+
}
|
504
|
+
|
505
|
+
if ($D.validateSecond(config.second)) {
|
506
|
+
this.addSeconds(config.second - this.getSeconds());
|
507
|
+
}
|
508
|
+
|
509
|
+
if ($D.validateMinute(config.minute)) {
|
510
|
+
this.addMinutes(config.minute - this.getMinutes());
|
511
|
+
}
|
512
|
+
|
513
|
+
if ($D.validateHour(config.hour)) {
|
514
|
+
this.addHours(config.hour - this.getHours());
|
515
|
+
}
|
516
|
+
|
517
|
+
if ($D.validateMonth(config.month)) {
|
518
|
+
this.addMonths(config.month - this.getMonth());
|
519
|
+
}
|
520
|
+
|
521
|
+
if ($D.validateYear(config.year)) {
|
522
|
+
this.addYears(config.year - this.getFullYear());
|
523
|
+
}
|
524
|
+
|
525
|
+
/* day has to go last because you can't validate the day without first knowing the month */
|
526
|
+
if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) {
|
527
|
+
this.addDays(config.day - this.getDate());
|
528
|
+
}
|
529
|
+
|
530
|
+
if (config.timezone) {
|
531
|
+
this.setTimezone(config.timezone);
|
532
|
+
}
|
533
|
+
|
534
|
+
if (config.timezoneOffset) {
|
535
|
+
this.setTimezoneOffset(config.timezoneOffset);
|
536
|
+
}
|
537
|
+
|
538
|
+
if (config.week && validate(config.week, 0, 53, "week")) {
|
539
|
+
this.setWeek(config.week);
|
540
|
+
}
|
541
|
+
|
542
|
+
return this;
|
543
|
+
};
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Moves the date to the first day of the month.
|
547
|
+
* @return {Date} this
|
548
|
+
*/
|
549
|
+
$P.moveToFirstDayOfMonth = function () {
|
550
|
+
return this.set({ day: 1 });
|
551
|
+
};
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Moves the date to the last day of the month.
|
555
|
+
* @return {Date} this
|
556
|
+
*/
|
557
|
+
$P.moveToLastDayOfMonth = function () {
|
558
|
+
return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())});
|
559
|
+
};
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month.
|
563
|
+
* @param {Number} The dayOfWeek to move to
|
564
|
+
* @param {Number} The n'th occurrence to move to. Use (-1) to return the last occurrence in the month
|
565
|
+
* @return {Date} this
|
566
|
+
*/
|
567
|
+
$P.moveToNthOccurrence = function (dayOfWeek, occurrence) {
|
568
|
+
var shift = 0;
|
569
|
+
if (occurrence > 0) {
|
570
|
+
shift = occurrence - 1;
|
571
|
+
}
|
572
|
+
else if (occurrence === -1) {
|
573
|
+
this.moveToLastDayOfMonth();
|
574
|
+
if (this.getDay() !== dayOfWeek) {
|
575
|
+
this.moveToDayOfWeek(dayOfWeek, -1);
|
576
|
+
}
|
577
|
+
return this;
|
578
|
+
}
|
579
|
+
return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift);
|
580
|
+
};
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Move to the next or last dayOfWeek based on the orient value.
|
584
|
+
* @param {Number} The dayOfWeek to move to
|
585
|
+
* @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional]
|
586
|
+
* @return {Date} this
|
587
|
+
*/
|
588
|
+
$P.moveToDayOfWeek = function (dayOfWeek, orient) {
|
589
|
+
var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7;
|
590
|
+
return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff);
|
591
|
+
};
|
592
|
+
|
593
|
+
/**
|
594
|
+
* Move to the next or last month based on the orient value.
|
595
|
+
* @param {Number} The month to move to. 0 = January, 11 = December
|
596
|
+
* @param {Number} Forward (+1) or Back (-1). Defaults to +1. [Optional]
|
597
|
+
* @return {Date} this
|
598
|
+
*/
|
599
|
+
$P.moveToMonth = function (month, orient) {
|
600
|
+
var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12;
|
601
|
+
return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff);
|
602
|
+
};
|
603
|
+
|
604
|
+
/**
|
605
|
+
* Get the Ordinal day (numeric day number) of the year, adjusted for leap year.
|
606
|
+
* @return {Number} 1 through 365 (366 in leap years)
|
607
|
+
*/
|
608
|
+
$P.getOrdinalNumber = function () {
|
609
|
+
return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1;
|
610
|
+
};
|
611
|
+
|
612
|
+
/**
|
613
|
+
* Get the time zone abbreviation of the current date.
|
614
|
+
* @return {String} The abbreviated time zone name (e.g. "EST")
|
615
|
+
*/
|
616
|
+
$P.getTimezone = function () {
|
617
|
+
return $D.getTimezoneAbbreviation(this.getUTCOffset());
|
618
|
+
};
|
619
|
+
|
620
|
+
$P.setTimezoneOffset = function (offset) {
|
621
|
+
var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10;
|
622
|
+
return this.addMinutes(there - here);
|
623
|
+
};
|
624
|
+
|
625
|
+
$P.setTimezone = function (offset) {
|
626
|
+
return this.setTimezoneOffset($D.getTimezoneOffset(offset));
|
627
|
+
};
|
628
|
+
|
629
|
+
/**
|
630
|
+
* Indicates whether Daylight Saving Time is observed in the current time zone.
|
631
|
+
* @return {Boolean} true|false
|
632
|
+
*/
|
633
|
+
$P.hasDaylightSavingTime = function () {
|
634
|
+
return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset());
|
635
|
+
};
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone.
|
639
|
+
* @return {Boolean} true|false
|
640
|
+
*/
|
641
|
+
$P.isDaylightSavingTime = function () {
|
642
|
+
return Date.today().set({month: 0, day: 1}).getTimezoneOffset() != this.getTimezoneOffset();
|
643
|
+
};
|
644
|
+
|
645
|
+
/**
|
646
|
+
* Get the offset from UTC of the current date.
|
647
|
+
* @return {String} The 4-character offset string prefixed with + or - (e.g. "-0500")
|
648
|
+
*/
|
649
|
+
$P.getUTCOffset = function () {
|
650
|
+
var n = this.getTimezoneOffset() * -10 / 6, r;
|
651
|
+
if (n < 0) {
|
652
|
+
r = (n - 10000).toString();
|
653
|
+
return r.charAt(0) + r.substr(2);
|
654
|
+
} else {
|
655
|
+
r = (n + 10000).toString();
|
656
|
+
return "+" + r.substr(1);
|
657
|
+
}
|
658
|
+
};
|
659
|
+
|
660
|
+
/**
|
661
|
+
* Returns the number of milliseconds between this date and date.
|
662
|
+
* @param {Date} Defaults to now
|
663
|
+
* @return {Number} The diff in milliseconds
|
664
|
+
*/
|
665
|
+
$P.getElapsed = function (date) {
|
666
|
+
return (date || new Date()) - this;
|
667
|
+
};
|
668
|
+
|
669
|
+
if (!$P.toISOString) {
|
670
|
+
/**
|
671
|
+
* Converts the current date instance into a string with an ISO 8601 format. The date is converted to it's UTC value.
|
672
|
+
* @return {String} ISO 8601 string of date
|
673
|
+
*/
|
674
|
+
$P.toISOString = function () {
|
675
|
+
// From http://www.json.org/json.js. Public Domain.
|
676
|
+
function f(n) {
|
677
|
+
return n < 10 ? '0' + n : n;
|
678
|
+
}
|
679
|
+
function h(i){
|
680
|
+
return i.length < 2 ? "00" + i :
|
681
|
+
i.length < 3 ? "0" + i :
|
682
|
+
3 < i.length ? Math.round(i/Math.pow(10,i.length-3)) : i
|
683
|
+
}
|
684
|
+
|
685
|
+
return '"' + this.getUTCFullYear() + '-' +
|
686
|
+
f(this.getUTCMonth() + 1) + '-' +
|
687
|
+
f(this.getUTCDate()) + 'T' +
|
688
|
+
f(this.getUTCHours()) + ':' +
|
689
|
+
f(this.getUTCMinutes()) + ':' +
|
690
|
+
f(this.getUTCSeconds()) + '.' +
|
691
|
+
h(this.getUTCMilliseconds()) + 'Z"';
|
692
|
+
};
|
693
|
+
}
|
694
|
+
|
695
|
+
// private
|
696
|
+
$P._toString = $P.toString;
|
697
|
+
|
698
|
+
/**
|
699
|
+
* Converts the value of the current Date object to its equivalent string representation.
|
700
|
+
* Format Specifiers
|
701
|
+
<pre>
|
702
|
+
CUSTOM DATE AND TIME FORMAT STRINGS
|
703
|
+
Format Description Example
|
704
|
+
------ --------------------------------------------------------------------------- -----------------------
|
705
|
+
s The seconds of the minute between 0-59. "0" to "59"
|
706
|
+
ss The seconds of the minute with leading zero if required. "00" to "59"
|
707
|
+
|
708
|
+
m The minute of the hour between 0-59. "0" or "59"
|
709
|
+
mm The minute of the hour with leading zero if required. "00" or "59"
|
710
|
+
|
711
|
+
h The hour of the day between 1-12. "1" to "12"
|
712
|
+
hh The hour of the day with leading zero if required. "01" to "12"
|
713
|
+
|
714
|
+
H The hour of the day between 0-23. "0" to "23"
|
715
|
+
HH The hour of the day with leading zero if required. "00" to "23"
|
716
|
+
|
717
|
+
d The day of the month between 1 and 31. "1" to "31"
|
718
|
+
dd The day of the month with leading zero if required. "01" to "31"
|
719
|
+
ddd Abbreviated day name. $C.abbreviatedDayNames. "Mon" to "Sun"
|
720
|
+
dddd The full day name. $C.dayNames. "Monday" to "Sunday"
|
721
|
+
|
722
|
+
M The month of the year between 1-12. "1" to "12"
|
723
|
+
MM The month of the year with leading zero if required. "01" to "12"
|
724
|
+
MMM Abbreviated month name. $C.abbreviatedMonthNames. "Jan" to "Dec"
|
725
|
+
MMMM The full month name. $C.monthNames. "January" to "December"
|
726
|
+
|
727
|
+
yy The year as a two-digit number. "99" or "08"
|
728
|
+
yyyy The full four digit year. "1999" or "2008"
|
729
|
+
|
730
|
+
t Displays the first character of the A.M./P.M. designator. "A" or "P"
|
731
|
+
$C.amDesignator or $C.pmDesignator
|
732
|
+
tt Displays the A.M./P.M. designator. "AM" or "PM"
|
733
|
+
$C.amDesignator or $C.pmDesignator
|
734
|
+
|
735
|
+
S The ordinal suffix ("st, "nd", "rd" or "th") of the current day. "st, "nd", "rd" or "th"
|
736
|
+
|
737
|
+
|| *Format* || *Description* || *Example* ||
|
738
|
+
|| d || The CultureInfo shortDate Format Pattern || "M/d/yyyy" ||
|
739
|
+
|| D || The CultureInfo longDate Format Pattern || "dddd, MMMM dd, yyyy" ||
|
740
|
+
|| F || The CultureInfo fullDateTime Format Pattern || "dddd, MMMM dd, yyyy h:mm:ss tt" ||
|
741
|
+
|| m || The CultureInfo monthDay Format Pattern || "MMMM dd" ||
|
742
|
+
|| r || The CultureInfo rfc1123 Format Pattern || "ddd, dd MMM yyyy HH:mm:ss GMT" ||
|
743
|
+
|| s || The CultureInfo sortableDateTime Format Pattern || "yyyy-MM-ddTHH:mm:ss" ||
|
744
|
+
|| t || The CultureInfo shortTime Format Pattern || "h:mm tt" ||
|
745
|
+
|| T || The CultureInfo longTime Format Pattern || "h:mm:ss tt" ||
|
746
|
+
|| u || The CultureInfo universalSortableDateTime Format Pattern || "yyyy-MM-dd HH:mm:ssZ" ||
|
747
|
+
|| y || The CultureInfo yearMonth Format Pattern || "MMMM, yyyy" ||
|
748
|
+
|
749
|
+
|
750
|
+
STANDARD DATE AND TIME FORMAT STRINGS
|
751
|
+
Format Description Example ("en-US")
|
752
|
+
------ --------------------------------------------------------------------------- -----------------------
|
753
|
+
d The CultureInfo shortDate Format Pattern "M/d/yyyy"
|
754
|
+
D The CultureInfo longDate Format Pattern "dddd, MMMM dd, yyyy"
|
755
|
+
F The CultureInfo fullDateTime Format Pattern "dddd, MMMM dd, yyyy h:mm:ss tt"
|
756
|
+
m The CultureInfo monthDay Format Pattern "MMMM dd"
|
757
|
+
r The CultureInfo rfc1123 Format Pattern "ddd, dd MMM yyyy HH:mm:ss GMT"
|
758
|
+
s The CultureInfo sortableDateTime Format Pattern "yyyy-MM-ddTHH:mm:ss"
|
759
|
+
t The CultureInfo shortTime Format Pattern "h:mm tt"
|
760
|
+
T The CultureInfo longTime Format Pattern "h:mm:ss tt"
|
761
|
+
u The CultureInfo universalSortableDateTime Format Pattern "yyyy-MM-dd HH:mm:ssZ"
|
762
|
+
y The CultureInfo yearMonth Format Pattern "MMMM, yyyy"
|
763
|
+
</pre>
|
764
|
+
* @param {String} A format string consisting of one or more format spcifiers [Optional].
|
765
|
+
* @return {String} A string representation of the current Date object.
|
766
|
+
*/
|
767
|
+
$P.toString = function (format) {
|
768
|
+
var x = this;
|
769
|
+
|
770
|
+
// Standard Date and Time Format Strings. Formats pulled from CultureInfo file and
|
771
|
+
// may vary by culture.
|
772
|
+
if (format && format.length == 1) {
|
773
|
+
var c = $C.formatPatterns;
|
774
|
+
x.t = x.toString;
|
775
|
+
switch (format) {
|
776
|
+
case "d":
|
777
|
+
return x.t(c.shortDate);
|
778
|
+
case "D":
|
779
|
+
return x.t(c.longDate);
|
780
|
+
case "F":
|
781
|
+
return x.t(c.fullDateTime);
|
782
|
+
case "m":
|
783
|
+
return x.t(c.monthDay);
|
784
|
+
case "r":
|
785
|
+
return x.t(c.rfc1123);
|
786
|
+
case "s":
|
787
|
+
return x.t(c.sortableDateTime);
|
788
|
+
case "t":
|
789
|
+
return x.t(c.shortTime);
|
790
|
+
case "T":
|
791
|
+
return x.t(c.longTime);
|
792
|
+
case "u":
|
793
|
+
return x.t(c.universalSortableDateTime);
|
794
|
+
case "y":
|
795
|
+
return x.t(c.yearMonth);
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
var ord = function (n) {
|
800
|
+
switch (n * 1) {
|
801
|
+
case 1:
|
802
|
+
case 21:
|
803
|
+
case 31:
|
804
|
+
return "st";
|
805
|
+
case 2:
|
806
|
+
case 22:
|
807
|
+
return "nd";
|
808
|
+
case 3:
|
809
|
+
case 23:
|
810
|
+
return "rd";
|
811
|
+
default:
|
812
|
+
return "th";
|
813
|
+
}
|
814
|
+
};
|
815
|
+
|
816
|
+
return format ? format.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g,
|
817
|
+
function (m) {
|
818
|
+
if (m.charAt(0) === "\\") {
|
819
|
+
return m.replace("\\", "");
|
820
|
+
}
|
821
|
+
x.h = x.getHours;
|
822
|
+
switch (m) {
|
823
|
+
case "hh":
|
824
|
+
return p(x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12));
|
825
|
+
case "h":
|
826
|
+
return x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12);
|
827
|
+
case "HH":
|
828
|
+
return p(x.h());
|
829
|
+
case "H":
|
830
|
+
return x.h();
|
831
|
+
case "mm":
|
832
|
+
return p(x.getMinutes());
|
833
|
+
case "m":
|
834
|
+
return x.getMinutes();
|
835
|
+
case "ss":
|
836
|
+
return p(x.getSeconds());
|
837
|
+
case "s":
|
838
|
+
return x.getSeconds();
|
839
|
+
case "yyyy":
|
840
|
+
return p(x.getFullYear(), 4);
|
841
|
+
case "yy":
|
842
|
+
return p(x.getFullYear());
|
843
|
+
case "dddd":
|
844
|
+
return $C.dayNames[x.getDay()];
|
845
|
+
case "ddd":
|
846
|
+
return $C.abbreviatedDayNames[x.getDay()];
|
847
|
+
case "dd":
|
848
|
+
return p(x.getDate());
|
849
|
+
case "d":
|
850
|
+
return x.getDate();
|
851
|
+
case "MMMM":
|
852
|
+
return $C.monthNames[x.getMonth()];
|
853
|
+
case "MMM":
|
854
|
+
return $C.abbreviatedMonthNames[x.getMonth()];
|
855
|
+
case "MM":
|
856
|
+
return p((x.getMonth() + 1));
|
857
|
+
case "M":
|
858
|
+
return x.getMonth() + 1;
|
859
|
+
case "t":
|
860
|
+
return x.h() < 12 ? $C.amDesignator.substring(0, 1) : $C.pmDesignator.substring(0, 1);
|
861
|
+
case "tt":
|
862
|
+
return x.h() < 12 ? $C.amDesignator : $C.pmDesignator;
|
863
|
+
case "S":
|
864
|
+
return ord(x.getDate());
|
865
|
+
default:
|
866
|
+
return m;
|
867
|
+
}
|
868
|
+
}
|
869
|
+
) : this._toString();
|
870
|
+
};
|
871
|
+
}());
|