@ui5/webcomponents-localization 0.0.0-c638668a1 → 0.0.0-cad512aa3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/.eslintrc.js +3 -0
  2. package/CHANGELOG.md +248 -0
  3. package/README.md +5 -6
  4. package/{src/Assets-static.js → dist/Assets-static.d.ts} +0 -1
  5. package/dist/Assets-static.js +1 -0
  6. package/dist/Assets-static.js.map +1 -0
  7. package/dist/Assets.d.ts +1 -0
  8. package/dist/Assets.js +1 -0
  9. package/dist/Assets.js.map +1 -0
  10. package/dist/DateFormat.d.ts +6 -0
  11. package/dist/DateFormat.js +6 -2
  12. package/dist/DateFormat.js.map +1 -0
  13. package/dist/LocaleData.d.ts +6 -0
  14. package/dist/LocaleData.js +6 -2
  15. package/dist/LocaleData.js.map +1 -0
  16. package/dist/dates/CalendarDate.d.ts +41 -0
  17. package/dist/dates/CalendarDate.js +170 -201
  18. package/dist/dates/CalendarDate.js.map +1 -0
  19. package/dist/dates/ExtremeDates.d.ts +5 -0
  20. package/dist/dates/ExtremeDates.js +25 -35
  21. package/dist/dates/ExtremeDates.js.map +1 -0
  22. package/dist/dates/UniversalDate.d.ts +46 -0
  23. package/dist/dates/UniversalDate.js +5 -0
  24. package/dist/dates/UniversalDate.js.map +1 -0
  25. package/dist/dates/calculateWeekNumber.d.ts +4 -0
  26. package/dist/dates/calculateWeekNumber.js +42 -48
  27. package/dist/dates/calculateWeekNumber.js.map +1 -0
  28. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  29. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  30. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  31. package/dist/dates/getDaysInMonth.d.ts +3 -0
  32. package/dist/dates/getDaysInMonth.js +10 -0
  33. package/dist/dates/getDaysInMonth.js.map +1 -0
  34. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  35. package/dist/dates/getRoundedTimestamp.js +9 -9
  36. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  37. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  38. package/dist/dates/getTodayUTCTimestamp.js +2 -3
  39. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  40. package/dist/dates/modifyDateBy.d.ts +13 -0
  41. package/dist/dates/modifyDateBy.js +27 -29
  42. package/dist/dates/modifyDateBy.js.map +1 -0
  43. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  44. package/dist/dates/transformDateToSecondaryType.js +17 -0
  45. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  46. package/dist/features/calendar/Buddhist.js +1 -0
  47. package/dist/features/calendar/Buddhist.js.map +1 -0
  48. package/dist/features/calendar/Gregorian.js +1 -0
  49. package/dist/features/calendar/Gregorian.js.map +1 -0
  50. package/dist/features/calendar/Islamic.js +1 -0
  51. package/dist/features/calendar/Islamic.js.map +1 -0
  52. package/dist/features/calendar/Japanese.js +1 -0
  53. package/dist/features/calendar/Japanese.js.map +1 -0
  54. package/dist/features/calendar/Persian.js +1 -0
  55. package/dist/features/calendar/Persian.js.map +1 -0
  56. package/dist/generated/assets/cldr/ar.json +2804 -5906
  57. package/dist/generated/assets/cldr/ar_EG.json +2804 -5906
  58. package/dist/generated/assets/cldr/ar_SA.json +2804 -5906
  59. package/dist/generated/assets/cldr/bg.json +2727 -4979
  60. package/dist/generated/assets/cldr/ca.json +2670 -4996
  61. package/dist/generated/assets/cldr/cs.json +2710 -5498
  62. package/dist/generated/assets/cldr/cy.json +2791 -5884
  63. package/dist/generated/assets/cldr/da.json +2591 -4888
  64. package/dist/generated/assets/cldr/de.json +2608 -4916
  65. package/dist/generated/assets/cldr/de_AT.json +2608 -4917
  66. package/dist/generated/assets/cldr/de_CH.json +2608 -4915
  67. package/dist/generated/assets/cldr/el.json +2589 -4883
  68. package/dist/generated/assets/cldr/el_CY.json +2589 -4883
  69. package/dist/generated/assets/cldr/en.json +2577 -4971
  70. package/dist/generated/assets/cldr/en_AU.json +2586 -4962
  71. package/dist/generated/assets/cldr/en_GB.json +2578 -4971
  72. package/dist/generated/assets/cldr/en_HK.json +2584 -4977
  73. package/dist/generated/assets/cldr/en_IE.json +2578 -4971
  74. package/dist/generated/assets/cldr/en_IN.json +2579 -4972
  75. package/dist/generated/assets/cldr/en_NZ.json +2578 -4971
  76. package/dist/generated/assets/cldr/en_PG.json +2578 -4972
  77. package/dist/generated/assets/cldr/en_SG.json +2579 -4973
  78. package/dist/generated/assets/cldr/en_ZA.json +2578 -4972
  79. package/dist/generated/assets/cldr/es.json +2633 -4912
  80. package/dist/generated/assets/cldr/es_AR.json +2638 -4914
  81. package/dist/generated/assets/cldr/es_BO.json +2638 -4913
  82. package/dist/generated/assets/cldr/es_CL.json +2638 -4914
  83. package/dist/generated/assets/cldr/es_CO.json +2637 -4913
  84. package/dist/generated/assets/cldr/es_MX.json +2638 -4915
  85. package/dist/generated/assets/cldr/es_PE.json +2638 -4913
  86. package/dist/generated/assets/cldr/es_UY.json +2638 -4915
  87. package/dist/generated/assets/cldr/es_VE.json +2638 -4914
  88. package/dist/generated/assets/cldr/et.json +2593 -4967
  89. package/dist/generated/assets/cldr/fa.json +2606 -4883
  90. package/dist/generated/assets/cldr/fi.json +2635 -5008
  91. package/dist/generated/assets/cldr/fr.json +2583 -4979
  92. package/dist/generated/assets/cldr/fr_BE.json +2583 -4979
  93. package/dist/generated/assets/cldr/fr_CA.json +2598 -4973
  94. package/dist/generated/assets/cldr/fr_CH.json +2600 -4997
  95. package/dist/generated/assets/cldr/fr_LU.json +2583 -4979
  96. package/dist/generated/assets/cldr/he.json +2699 -5378
  97. package/dist/generated/assets/cldr/hi.json +2593 -4829
  98. package/dist/generated/assets/cldr/hr.json +2646 -4919
  99. package/dist/generated/assets/cldr/hu.json +2592 -4856
  100. package/dist/generated/assets/cldr/id.json +2538 -4658
  101. package/dist/generated/assets/cldr/it.json +2583 -4950
  102. package/dist/generated/assets/cldr/it_CH.json +2583 -4950
  103. package/dist/generated/assets/cldr/ja.json +2655 -4830
  104. package/dist/generated/assets/cldr/kk.json +2583 -4725
  105. package/dist/generated/assets/cldr/ko.json +2632 -4738
  106. package/dist/generated/assets/cldr/lt.json +2714 -5481
  107. package/dist/generated/assets/cldr/lv.json +2638 -5112
  108. package/dist/generated/assets/cldr/ms.json +2532 -4515
  109. package/dist/generated/assets/cldr/nb.json +2615 -4977
  110. package/dist/generated/assets/cldr/nl.json +2595 -4884
  111. package/dist/generated/assets/cldr/nl_BE.json +2595 -4884
  112. package/dist/generated/assets/cldr/pl.json +2717 -5176
  113. package/dist/generated/assets/cldr/pt.json +2600 -4805
  114. package/dist/generated/assets/cldr/pt_PT.json +2651 -4940
  115. package/dist/generated/assets/cldr/ro.json +2639 -5090
  116. package/dist/generated/assets/cldr/ru.json +2698 -5407
  117. package/dist/generated/assets/cldr/ru_UA.json +2698 -5407
  118. package/dist/generated/assets/cldr/sk.json +2720 -5370
  119. package/dist/generated/assets/cldr/sl.json +2682 -5340
  120. package/dist/generated/assets/cldr/sr.json +2657 -5126
  121. package/dist/generated/assets/cldr/sr_Latn.json +2658 -5127
  122. package/dist/generated/assets/cldr/sv.json +2625 -5011
  123. package/dist/generated/assets/cldr/th.json +2626 -4797
  124. package/dist/generated/assets/cldr/tr.json +2606 -4979
  125. package/dist/generated/assets/cldr/uk.json +2678 -5353
  126. package/dist/generated/assets/cldr/vi.json +2549 -4673
  127. package/dist/generated/assets/cldr/zh_CN.json +2541 -4632
  128. package/dist/generated/assets/cldr/zh_HK.json +2549 -4640
  129. package/dist/generated/assets/cldr/zh_SG.json +2548 -4640
  130. package/dist/generated/assets/cldr/zh_TW.json +2556 -4728
  131. package/dist/generated/json-imports/LocaleData-static.js +2 -1
  132. package/dist/generated/json-imports/LocaleData.js +2 -1
  133. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  134. package/dist/getCachedLocaleDataInstance.js +6 -9
  135. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  136. package/dist/locale/getLocaleData.d.ts +11 -0
  137. package/dist/locale/getLocaleData.js +13 -17
  138. package/dist/locale/getLocaleData.js.map +1 -0
  139. package/dist/sap/base/Log.js +28 -29
  140. package/dist/sap/base/assert.js +5 -6
  141. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  142. package/dist/sap/base/util/LoaderExtensions.js +9 -12
  143. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  144. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  145. package/dist/sap/ui/core/Configuration.js +20 -0
  146. package/dist/sap/ui/core/Configuration.js.map +1 -0
  147. package/dist/sap/ui/core/Core.d.ts +26 -0
  148. package/dist/sap/ui/core/Core.js +7 -32
  149. package/dist/sap/ui/core/Core.js.map +1 -0
  150. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  151. package/dist/sap/ui/core/FormatSettings.js +14 -0
  152. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  153. package/dist/sap/ui/core/Locale.js +13 -0
  154. package/dist/sap/ui/core/LocaleData.js +107 -6
  155. package/dist/sap/ui/core/date/Buddhist.js +0 -6
  156. package/dist/sap/ui/core/date/CalendarUtils.js +36 -0
  157. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +7 -0
  158. package/dist/sap/ui/core/date/Islamic.js +3 -3
  159. package/dist/sap/ui/core/date/Japanese.js +4 -4
  160. package/dist/sap/ui/core/date/UniversalDate.js +79 -22
  161. package/dist/sap/ui/core/format/DateFormat.js +496 -201
  162. package/dist/sap/ui/core/format/TimezoneUtil.js +94 -0
  163. package/package-scripts.js +7 -9
  164. package/package.json +6 -5
  165. package/tsconfig.json +14 -0
  166. package/used-modules.txt +4 -1
  167. package/hash.txt +0 -1
  168. package/src/Assets.js +0 -2
  169. package/src/DateFormat.js +0 -3
  170. package/src/LocaleData.js +0 -3
  171. package/src/dates/CalendarDate.js +0 -223
  172. package/src/dates/ExtremeDates.js +0 -39
  173. package/src/dates/calculateWeekNumber.js +0 -51
  174. package/src/dates/getRoundedTimestamp.js +0 -14
  175. package/src/dates/getTodayUTCTimestamp.js +0 -9
  176. package/src/dates/modifyDateBy.js +0 -42
  177. package/src/getCachedLocaleDataInstance.js +0 -13
  178. package/src/locale/getLocaleData.js +0 -27
  179. package/src/sap/base/util/LoaderExtensions.js +0 -17
  180. package/src/sap/ui/core/Core.js +0 -38
  181. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  182. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  183. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  184. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  185. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -1,51 +1,45 @@
1
- import UniversalDate from "../sap/ui/core/date/UniversalDate.js";
2
-
1
+ import UniversalDate from "./UniversalDate.js";
3
2
  const calculateWeekNumber = (confFirstDayOfWeek, oDate, iYear, oLocale, oLocaleData) => {
4
- let iWeekNum = 0;
5
- let iWeekDay = 0;
6
- const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek : oLocaleData.getFirstDayOfWeek();
7
-
8
- // search Locale for containing "en-US", since sometimes
9
- // when any user settings have been defined, subtag "sapufmt" is added to the locale name
10
- // this is described inside sap.ui.core.Configuration file
11
- if (oLocale && (oLocale.getLanguage() === "en" && oLocale.getRegion() === "US")) {
12
- /*
13
- * in US the week starts with Sunday
14
- * The first week of the year starts with January 1st. But Dec. 31 is still in the last year
15
- * So the week beginning in December and ending in January has 2 week numbers
16
- */
17
- const oJanFirst = new UniversalDate(oDate.getTime());
18
- oJanFirst.setUTCFullYear(iYear, 0, 1);
19
- iWeekDay = oJanFirst.getUTCDay();
20
-
21
- // get the date for the same weekday like jan 1.
22
- const oCheckDate = new UniversalDate(oDate.getTime());
23
- oCheckDate.setUTCDate(oCheckDate.getUTCDate() - oCheckDate.getUTCDay() + iWeekDay);
24
-
25
- iWeekNum = Math.round((oCheckDate.getTime() - oJanFirst.getTime()) / 86400000 / 7) + 1;
26
- } else {
27
- // normally the first week of the year is the one where the first Thursday of the year is
28
- // find Thursday of this week
29
- // if the checked day is before the 1. day of the week use a day of the previous week to check
30
- const oThursday = new UniversalDate(oDate.getTime());
31
- oThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);
32
- iWeekDay = oThursday.getUTCDay();
33
- oThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);
34
-
35
- const oFirstDayOfYear = new UniversalDate(oThursday.getTime());
36
- oFirstDayOfYear.setUTCMonth(0, 1);
37
- iWeekDay = oFirstDayOfYear.getUTCDay();
38
- let iAddDays = 0;
39
- if (iWeekDay > 4) {
40
- iAddDays = 7; // first day of year is after Thursday, so first Thursday is in the next week
41
- }
42
- const oFirstThursday = new UniversalDate(oFirstDayOfYear.getTime());
43
- oFirstThursday.setUTCDate(1 - iWeekDay + 4 + iAddDays);
44
-
45
- iWeekNum = Math.round((oThursday.getTime() - oFirstThursday.getTime()) / 86400000 / 7) + 1;
46
- }
47
-
48
- return iWeekNum;
3
+ let iWeekNum = 0;
4
+ let iWeekDay = 0;
5
+ const iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek : oLocaleData.getFirstDayOfWeek();
6
+ // search Locale for containing "en-US", since sometimes
7
+ // when any user settings have been defined, subtag "sapufmt" is added to the locale name
8
+ // this is described inside sap.ui.core.Configuration file
9
+ if (oLocale && (oLocale.getLanguage() === "en" && oLocale.getRegion() === "US")) {
10
+ /*
11
+ * in US the week starts with Sunday
12
+ * The first week of the year starts with January 1st. But Dec. 31 is still in the last year
13
+ * So the week beginning in December and ending in January has 2 week numbers
14
+ */
15
+ const oJanFirst = new UniversalDate(oDate.getTime());
16
+ oJanFirst.setUTCFullYear(iYear, 0, 1);
17
+ iWeekDay = oJanFirst.getUTCDay();
18
+ // get the date for the same weekday like jan 1.
19
+ const oCheckDate = new UniversalDate(oDate.getTime());
20
+ oCheckDate.setUTCDate(oCheckDate.getUTCDate() - oCheckDate.getUTCDay() + iWeekDay);
21
+ iWeekNum = Math.round((oCheckDate.getTime() - oJanFirst.getTime()) / 86400000 / 7) + 1;
22
+ }
23
+ else {
24
+ // normally the first week of the year is the one where the first Thursday of the year is
25
+ // find Thursday of this week
26
+ // if the checked day is before the 1. day of the week use a day of the previous week to check
27
+ const oThursday = new UniversalDate(oDate.getTime());
28
+ oThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);
29
+ iWeekDay = oThursday.getUTCDay();
30
+ oThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);
31
+ const oFirstDayOfYear = new UniversalDate(oThursday.getTime());
32
+ oFirstDayOfYear.setUTCMonth(0, 1);
33
+ iWeekDay = oFirstDayOfYear.getUTCDay();
34
+ let iAddDays = 0;
35
+ if (iWeekDay > 4) {
36
+ iAddDays = 7; // first day of year is after Thursday, so first Thursday is in the next week
37
+ }
38
+ const oFirstThursday = new UniversalDate(oFirstDayOfYear.getTime());
39
+ oFirstThursday.setUTCDate(1 - iWeekDay + 4 + iAddDays);
40
+ iWeekNum = Math.round((oThursday.getTime() - oFirstThursday.getTime()) / 86400000 / 7) + 1;
41
+ }
42
+ return iWeekNum;
49
43
  };
50
-
51
44
  export default calculateWeekNumber;
45
+ //# sourceMappingURL=calculateWeekNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateWeekNumber.js","sourceRoot":"","sources":["../../src/dates/calculateWeekNumber.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAG/C,MAAM,mBAAmB,GAAG,CAAC,kBAAsC,EAAE,KAAW,EAAE,KAAa,EAAE,OAAe,EAAE,WAAuB,EAAE,EAAE;IAC5I,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,kBAAmB,CAAC,CAAC,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC;IAErH,wDAAwD;IACxD,yFAAyF;IACzF,0DAA0D;IAC1D,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,CAAC,EAAE;QAChF;;;;cAIG;QACH,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,QAAQ,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QAEjC,gDAAgD;QAChD,MAAM,UAAU,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACtD,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,CAAC;QAEnF,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;KACvF;SAAM;QACN,yFAAyF;QACzF,6BAA6B;QAC7B,8FAA8F;QAC9F,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,eAAe,CAAC,CAAC;QAC/D,QAAQ,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACjC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC;QAE5D,MAAM,eAAe,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,eAAe,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,CAAC;QACvC,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,QAAQ,GAAG,CAAC,EAAE;YACjB,QAAQ,GAAG,CAAC,CAAC,CAAC,6EAA6E;SAC3F;QACD,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACpE,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAEvD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;KAC3F;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import type Locale from \"@ui5/webcomponents-base/dist/locale/Locale.js\";\nimport UniversalDate from \"./UniversalDate.js\";\nimport type LocaleData from \"../LocaleData.js\";\n\nconst calculateWeekNumber = (confFirstDayOfWeek: number | undefined, oDate: Date, iYear: number, oLocale: Locale, oLocaleData: LocaleData) => {\n\tlet iWeekNum = 0;\n\tlet iWeekDay = 0;\n\tconst iFirstDayOfWeek = Number.isInteger(confFirstDayOfWeek) ? confFirstDayOfWeek! : oLocaleData.getFirstDayOfWeek();\n\n\t// search Locale for containing \"en-US\", since sometimes\n\t// when any user settings have been defined, subtag \"sapufmt\" is added to the locale name\n\t// this is described inside sap.ui.core.Configuration file\n\tif (oLocale && (oLocale.getLanguage() === \"en\" && oLocale.getRegion() === \"US\")) {\n\t\t/*\n\t\t\t* in US the week starts with Sunday\n\t\t\t* The first week of the year starts with January 1st. But Dec. 31 is still in the last year\n\t\t\t* So the week beginning in December and ending in January has 2 week numbers\n\t\t\t*/\n\t\tconst oJanFirst = new UniversalDate(oDate.getTime());\n\t\toJanFirst.setUTCFullYear(iYear, 0, 1);\n\t\tiWeekDay = oJanFirst.getUTCDay();\n\n\t\t// get the date for the same weekday like jan 1.\n\t\tconst oCheckDate = new UniversalDate(oDate.getTime());\n\t\toCheckDate.setUTCDate(oCheckDate.getUTCDate() - oCheckDate.getUTCDay() + iWeekDay);\n\n\t\tiWeekNum = Math.round((oCheckDate.getTime() - oJanFirst.getTime()) / 86400000 / 7) + 1;\n\t} else {\n\t\t// normally the first week of the year is the one where the first Thursday of the year is\n\t\t// find Thursday of this week\n\t\t// if the checked day is before the 1. day of the week use a day of the previous week to check\n\t\tconst oThursday = new UniversalDate(oDate.getTime());\n\t\toThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);\n\t\tiWeekDay = oThursday.getUTCDay();\n\t\toThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);\n\n\t\tconst oFirstDayOfYear = new UniversalDate(oThursday.getTime());\n\t\toFirstDayOfYear.setUTCMonth(0, 1);\n\t\tiWeekDay = oFirstDayOfYear.getUTCDay();\n\t\tlet iAddDays = 0;\n\t\tif (iWeekDay > 4) {\n\t\t\tiAddDays = 7; // first day of year is after Thursday, so first Thursday is in the next week\n\t\t}\n\t\tconst oFirstThursday = new UniversalDate(oFirstDayOfYear.getTime());\n\t\toFirstThursday.setUTCDate(1 - iWeekDay + 4 + iAddDays);\n\n\t\tiWeekNum = Math.round((oThursday.getTime() - oFirstThursday.getTime()) / 86400000 / 7) + 1;\n\t}\n\n\treturn iWeekNum;\n};\n\nexport default calculateWeekNumber;\n"]}
@@ -0,0 +1,16 @@
1
+ import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
+ /**
3
+ * Convert month number to month name (text).
4
+ * If the numbers of the two months are the same you will get the name of the month,
5
+ * otherwise you will get the two names separated by a dash
6
+ *
7
+ * @param firstMonth CalendarDate Month
8
+ * @param lastMonth CalendarDate Month
9
+ * @param calendarType calendar type
10
+ * @returns {String}
11
+ */
12
+ declare const convertMonthNumbersToMonthNames: (firstMonth: number, lastMonth: number, calendarType?: CalendarType) => {
13
+ text: any;
14
+ textInfo: any;
15
+ };
16
+ export default convertMonthNumbersToMonthNames;
@@ -0,0 +1,30 @@
1
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
2
+ import getCachedLocaleDataInstance from "../getCachedLocaleDataInstance.js";
3
+ /**
4
+ * Convert month number to month name (text).
5
+ * If the numbers of the two months are the same you will get the name of the month,
6
+ * otherwise you will get the two names separated by a dash
7
+ *
8
+ * @param firstMonth CalendarDate Month
9
+ * @param lastMonth CalendarDate Month
10
+ * @param calendarType calendar type
11
+ * @returns {String}
12
+ */
13
+ const convertMonthNumbersToMonthNames = (firstMonth, lastMonth, calendarType) => {
14
+ const localeData = getCachedLocaleDataInstance(getLocale());
15
+ const pattern = localeData.getIntervalPattern("");
16
+ const secondaryMonthsNames = localeData.getMonthsStandAlone("abbreviated", calendarType);
17
+ const secondaryMonthsNamesWide = localeData.getMonthsStandAlone("wide", calendarType);
18
+ if (firstMonth === lastMonth) {
19
+ return {
20
+ text: localeData.getMonths("abbreviated", calendarType)[firstMonth],
21
+ textInfo: localeData.getMonths("wide", calendarType)[firstMonth],
22
+ };
23
+ }
24
+ return {
25
+ text: pattern.replace(/\{0\}/, secondaryMonthsNames[firstMonth]).replace(/\{1\}/, secondaryMonthsNames[lastMonth]),
26
+ textInfo: pattern.replace(/\{0\}/, secondaryMonthsNamesWide[firstMonth]).replace(/\{1\}/, secondaryMonthsNamesWide[lastMonth]),
27
+ };
28
+ };
29
+ export default convertMonthNumbersToMonthNames;
30
+ //# sourceMappingURL=convertMonthNumbersToMonthNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertMonthNumbersToMonthNames.js","sourceRoot":"","sources":["../../src/dates/convertMonthNumbersToMonthNames.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kDAAkD,CAAC;AAEzE,OAAO,2BAA2B,MAAM,mCAAmC,CAAC;AAE5E;;;;;;;;;GASG;AACH,MAAM,+BAA+B,GAAG,CAAC,UAAkB,EAAE,SAAiB,EAAE,YAA2B,EAAE,EAAE;IAC9G,MAAM,UAAU,GAAG,2BAA2B,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAClD,MAAM,oBAAoB,GAAG,UAAU,CAAC,mBAAmB,CAAC,aAAa,EAAE,YAAY,CAAkB,CAAC;IAC1G,MAAM,wBAAwB,GAAG,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAkB,CAAC;IAEvG,IAAI,UAAU,KAAK,SAAS,EAAE;QAC7B,OAAO;YACN,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,UAAU,CAAC;YACnE,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,UAAU,CAAC;SAChE,CAAC;KACF;IAED,OAAO;QACN,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAClH,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;KAC9H,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,+BAA+B,CAAC","sourcesContent":["import getLocale from \"@ui5/webcomponents-base/dist/locale/getLocale.js\";\nimport type CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport getCachedLocaleDataInstance from \"../getCachedLocaleDataInstance.js\";\n\n/**\n * Convert month number to month name (text).\n * If the numbers of the two months are the same you will get the name of the month,\n * otherwise you will get the two names separated by a dash\n *\n * @param firstMonth CalendarDate Month\n * @param lastMonth CalendarDate Month\n * @param calendarType calendar type\n * @returns {String}\n */\nconst convertMonthNumbersToMonthNames = (firstMonth: number, lastMonth: number, calendarType?: CalendarType) => {\n\tconst localeData = getCachedLocaleDataInstance(getLocale());\n\tconst pattern = localeData.getIntervalPattern(\"\");\n\tconst secondaryMonthsNames = localeData.getMonthsStandAlone(\"abbreviated\", calendarType) as Array<string>;\n\tconst secondaryMonthsNamesWide = localeData.getMonthsStandAlone(\"wide\", calendarType) as Array<string>;\n\n\tif (firstMonth === lastMonth) {\n\t\treturn {\n\t\t\ttext: localeData.getMonths(\"abbreviated\", calendarType)[firstMonth],\n\t\t\ttextInfo: localeData.getMonths(\"wide\", calendarType)[firstMonth],\n\t\t};\n\t}\n\n\treturn {\n\t\ttext: pattern.replace(/\\{0\\}/, secondaryMonthsNames[firstMonth]).replace(/\\{1\\}/, secondaryMonthsNames[lastMonth]),\n\t\ttextInfo: pattern.replace(/\\{0\\}/, secondaryMonthsNamesWide[firstMonth]).replace(/\\{1\\}/, secondaryMonthsNamesWide[lastMonth]),\n\t};\n};\n\nexport default convertMonthNumbersToMonthNames;\n"]}
@@ -0,0 +1,3 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ declare const getDaysInMonth: (date: CalendarDate) => number;
3
+ export default getDaysInMonth;
@@ -0,0 +1,10 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ const getDaysInMonth = (date) => {
3
+ const tempCalendarDate = new CalendarDate(date);
4
+ tempCalendarDate.setDate(1);
5
+ tempCalendarDate.setMonth(tempCalendarDate.getMonth() + 1);
6
+ tempCalendarDate.setDate(0);
7
+ return tempCalendarDate.getDate();
8
+ };
9
+ export default getDaysInMonth;
10
+ //# sourceMappingURL=getDaysInMonth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDaysInMonth.js","sourceRoot":"","sources":["../../src/dates/getDaysInMonth.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,MAAM,cAAc,GAAG,CAAC,IAAkB,EAAE,EAAE;IAC7C,MAAM,gBAAgB,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAChD,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,gBAAgB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3D,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import CalendarDate from \"./CalendarDate.js\";\n\nconst getDaysInMonth = (date: CalendarDate) => {\n\tconst tempCalendarDate = new CalendarDate(date);\n\ttempCalendarDate.setDate(1);\n\ttempCalendarDate.setMonth(tempCalendarDate.getMonth() + 1);\n\ttempCalendarDate.setDate(0);\n\treturn tempCalendarDate.getDate();\n};\n\nexport default getDaysInMonth;\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns a timestamp with only the year, month and day (with zero hours, minutes and seconds) and without 000 for milliseconds
3
+ * @param { number } millisecondsUTC
4
+ * @returns { number }
5
+ */
6
+ declare const getRoundedTimestamp: (millisecondsUTC: number) => number;
7
+ export default getRoundedTimestamp;
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Returns a timestamp with only the year, month and day (with zero hours, minutes and seconds) and without 000 for milliseconds
3
- * @param millisecondsUTC
4
- * @returns {number}
3
+ * @param { number } millisecondsUTC
4
+ * @returns { number }
5
5
  */
6
- const getRoundedTimestamp = millisecondsUTC => {
7
- if (!millisecondsUTC) {
8
- millisecondsUTC = new Date().getTime();
9
- }
10
- const rounded = millisecondsUTC - (millisecondsUTC % (24 * 60 * 60 * 1000));
11
- return rounded / 1000;
6
+ const getRoundedTimestamp = (millisecondsUTC) => {
7
+ if (!millisecondsUTC) {
8
+ millisecondsUTC = new Date().getTime();
9
+ }
10
+ const rounded = millisecondsUTC - (millisecondsUTC % (24 * 60 * 60 * 1000));
11
+ return rounded / 1000;
12
12
  };
13
-
14
13
  export default getRoundedTimestamp;
14
+ //# sourceMappingURL=getRoundedTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRoundedTimestamp.js","sourceRoot":"","sources":["../../src/dates/getRoundedTimestamp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,eAAuB,EAAE,EAAE;IACvD,IAAI,CAAC,eAAe,EAAE;QACrB,eAAe,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;KACvC;IACD,MAAM,OAAO,GAAG,eAAe,GAAG,CAAC,eAAe,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5E,OAAO,OAAO,GAAG,IAAI,CAAC;AACvB,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["/**\n * Returns a timestamp with only the year, month and day (with zero hours, minutes and seconds) and without 000 for milliseconds\n * @param { number } millisecondsUTC\n * @returns { number }\n */\nconst getRoundedTimestamp = (millisecondsUTC: number) => {\n\tif (!millisecondsUTC) {\n\t\tmillisecondsUTC = new Date().getTime();\n\t}\n\tconst rounded = millisecondsUTC - (millisecondsUTC % (24 * 60 * 60 * 1000));\n\treturn rounded / 1000;\n};\n\nexport default getRoundedTimestamp;\n"]}
@@ -0,0 +1,7 @@
1
+ import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
+ /**
3
+ * Returns a UTC timestamp representing today
4
+ * @public
5
+ */
6
+ declare const getTodayUTCTimestamp: (primaryCalendarType: CalendarType) => number;
7
+ export default getTodayUTCTimestamp;
@@ -1,9 +1,8 @@
1
1
  import CalendarDate from "./CalendarDate.js";
2
-
3
2
  /**
4
3
  * Returns a UTC timestamp representing today
5
4
  * @public
6
5
  */
7
- const getTodayUTCTimestamp = primaryCalendarType => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
8
-
6
+ const getTodayUTCTimestamp = (primaryCalendarType) => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
9
7
  export default getTodayUTCTimestamp;
8
+ //# sourceMappingURL=getTodayUTCTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTodayUTCTimestamp.js","sourceRoot":"","sources":["../../src/dates/getTodayUTCTimestamp.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,mBAAiC,EAAE,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE,EAAE,mBAAmB,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAEnJ,eAAe,oBAAoB,CAAC","sourcesContent":["import type CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport CalendarDate from \"./CalendarDate.js\";\n\n/**\n * Returns a UTC timestamp representing today\n * @public\n */\nconst getTodayUTCTimestamp = (primaryCalendarType: CalendarType) => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;\n\nexport default getTodayUTCTimestamp;\n"]}
@@ -0,0 +1,13 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ /**
3
+ * Adds or subtracts a given amount of days/months/years from a date.
4
+ * If minDate or maxDate are given, the result will be enforced within these limits
5
+ *
6
+ * @param date CalendarDate instance
7
+ * @param amount how many days/months/years to add (can be a negative number)
8
+ * @param unit what to modify: "day", "month" or "year"
9
+ * @param minDate minimum date to enforce
10
+ * @param maxDate maximum date to enforce
11
+ */
12
+ declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
13
+ export default modifyDateBy;
@@ -1,5 +1,4 @@
1
1
  import CalendarDate from "./CalendarDate.js";
2
-
3
2
  /**
4
3
  * Adds or subtracts a given amount of days/months/years from a date.
5
4
  * If minDate or maxDate are given, the result will be enforced within these limits
@@ -10,33 +9,32 @@ import CalendarDate from "./CalendarDate.js";
10
9
  * @param minDate minimum date to enforce
11
10
  * @param maxDate maximum date to enforce
12
11
  */
13
- const modifyDateBy = (date, amount, unit, minDate = null, maxDate = null) => {
14
- const newDate = new CalendarDate(date);
15
- if (unit === "day") {
16
- newDate.setDate(date.getDate() + amount);
17
- } else if (unit === "month") {
18
- newDate.setMonth(date.getMonth() + amount);
19
- const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
20
- const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
21
- if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
22
- newDate.setDate(0);
23
- }
24
- } else {
25
- newDate.setYear(date.getYear() + amount);
26
- if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
27
- newDate.setDate(0); // Select the last day of the month
28
- }
29
- }
30
-
31
- if (minDate && newDate.valueOf() < minDate.valueOf()) {
32
- return new CalendarDate(minDate);
33
- }
34
-
35
- if (maxDate && newDate.valueOf() > maxDate.valueOf()) {
36
- return new CalendarDate(maxDate);
37
- }
38
-
39
- return newDate;
12
+ const modifyDateBy = (date, amount, unit, minDate, maxDate) => {
13
+ const newDate = new CalendarDate(date);
14
+ if (unit === "day") {
15
+ newDate.setDate(date.getDate() + amount);
16
+ }
17
+ else if (unit === "month") {
18
+ newDate.setMonth(date.getMonth() + amount);
19
+ const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
20
+ const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
21
+ if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
22
+ newDate.setDate(0);
23
+ }
24
+ }
25
+ else {
26
+ newDate.setYear(date.getYear() + amount);
27
+ if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
28
+ newDate.setDate(0); // Select the last day of the month
29
+ }
30
+ }
31
+ if (minDate && newDate.valueOf() < minDate.valueOf()) {
32
+ return new CalendarDate(minDate);
33
+ }
34
+ if (maxDate && newDate.valueOf() > maxDate.valueOf()) {
35
+ return new CalendarDate(maxDate);
36
+ }
37
+ return newDate;
40
38
  };
41
-
42
39
  export default modifyDateBy;
40
+ //# sourceMappingURL=modifyDateBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifyDateBy.js","sourceRoot":"","sources":["../../src/dates/modifyDateBy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,OAAsB,EAAE,OAAsB,EAAE,EAAE;IACzH,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,IAAI,KAAK,KAAK,EAAE;QACnB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;KACzC;SAAM,IAAI,IAAI,KAAK,OAAO,EAAE;QAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,yCAAyC;QACzH,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,sCAAsC;QACrH,IAAI,cAAc,IAAI,YAAY,EAAE,EAAE,+DAA+D;YACpG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACnB;KACD;SAAM;QACN,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;QACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,kCAAkC;YAC/E,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;SACvD;KACD;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE;QACrD,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE;QACrD,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import CalendarDate from \"./CalendarDate.js\";\n\n/**\n * Adds or subtracts a given amount of days/months/years from a date.\n * If minDate or maxDate are given, the result will be enforced within these limits\n *\n * @param date CalendarDate instance\n * @param amount how many days/months/years to add (can be a negative number)\n * @param unit what to modify: \"day\", \"month\" or \"year\"\n * @param minDate minimum date to enforce\n * @param maxDate maximum date to enforce\n */\nconst modifyDateBy = (date: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => {\n\tconst newDate = new CalendarDate(date);\n\tif (unit === \"day\") {\n\t\tnewDate.setDate(date.getDate() + amount);\n\t} else if (unit === \"month\") {\n\t\tnewDate.setMonth(date.getMonth() + amount);\n\t\tconst stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month\n\t\tconst monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month\n\t\tif (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios\n\t\t\tnewDate.setDate(0);\n\t\t}\n\t} else {\n\t\tnewDate.setYear(date.getYear() + amount);\n\t\tif (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year\n\t\t\tnewDate.setDate(0); // Select the last day of the month\n\t\t}\n\t}\n\n\tif (minDate && newDate.valueOf() < minDate.valueOf()) {\n\t\treturn new CalendarDate(minDate);\n\t}\n\n\tif (maxDate && newDate.valueOf() > maxDate.valueOf()) {\n\t\treturn new CalendarDate(maxDate);\n\t}\n\n\treturn newDate;\n};\n\nexport default modifyDateBy;\n"]}
@@ -0,0 +1,7 @@
1
+ import type CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js";
2
+ import CalendarDate from "./CalendarDate.js";
3
+ declare const transformDateToSecondaryType: (primaryCalendarType: CalendarType | undefined, secondaryCalendarType: CalendarType | undefined, timeStamp: number, hasYearPicker?: boolean) => {
4
+ firstDate: CalendarDate;
5
+ lastDate: CalendarDate;
6
+ };
7
+ export default transformDateToSecondaryType;
@@ -0,0 +1,17 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ import getDaysInMonth from "./getDaysInMonth.js";
3
+ const transformDateToSecondaryType = (primaryCalendarType, secondaryCalendarType, timeStamp, hasYearPicker) => {
4
+ let firstDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
5
+ let lastDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);
6
+ firstDate.setDate(1);
7
+ if (hasYearPicker) {
8
+ firstDate.setMonth(0);
9
+ lastDate.setMonth(11);
10
+ }
11
+ lastDate.setDate(getDaysInMonth(lastDate));
12
+ firstDate = new CalendarDate(firstDate, secondaryCalendarType);
13
+ lastDate = new CalendarDate(lastDate, secondaryCalendarType);
14
+ return { firstDate, lastDate };
15
+ };
16
+ export default transformDateToSecondaryType;
17
+ //# sourceMappingURL=transformDateToSecondaryType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformDateToSecondaryType.js","sourceRoot":"","sources":["../../src/dates/transformDateToSecondaryType.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,4BAA4B,GAAG,CAAC,mBAA6C,EAAE,qBAA8C,EAAE,SAAiB,EAAE,aAAuB,EAAE,EAAE;IAClL,IAAI,SAAS,GAAG,YAAY,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAC9F,IAAI,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAC7F,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAErB,IAAI,aAAa,EAAE;QAClB,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;KACtB;IAED,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3C,SAAS,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAC/D,QAAQ,GAAG,IAAI,YAAY,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC7D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,eAAe,4BAA4B,CAAC","sourcesContent":["import type CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport CalendarDate from \"./CalendarDate.js\";\nimport getDaysInMonth from \"./getDaysInMonth.js\";\n\nconst transformDateToSecondaryType = (primaryCalendarType: CalendarType | undefined, secondaryCalendarType: CalendarType| undefined, timeStamp: number, hasYearPicker?: boolean) => {\n\tlet firstDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);\n\tlet lastDate = CalendarDate.fromLocalJSDate(new Date(timeStamp * 1000), primaryCalendarType);\n\tfirstDate.setDate(1);\n\n\tif (hasYearPicker) {\n\t\tfirstDate.setMonth(0);\n\t\tlastDate.setMonth(11);\n\t}\n\n\tlastDate.setDate(getDaysInMonth(lastDate));\n\tfirstDate = new CalendarDate(firstDate, secondaryCalendarType);\n\tlastDate = new CalendarDate(lastDate, secondaryCalendarType);\n\treturn { firstDate, lastDate };\n};\n\nexport default transformDateToSecondaryType;\n"]}
@@ -1 +1,2 @@
1
1
  import "../../sap/ui/core/date/Buddhist.js";
2
+ //# sourceMappingURL=Buddhist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Buddhist.js","sourceRoot":"","sources":["../../../src/features/calendar/Buddhist.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC","sourcesContent":["import \"../../sap/ui/core/date/Buddhist.js\";\n"]}
@@ -1 +1,2 @@
1
1
  import "../../sap/ui/core/date/Gregorian.js";
2
+ //# sourceMappingURL=Gregorian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gregorian.js","sourceRoot":"","sources":["../../../src/features/calendar/Gregorian.ts"],"names":[],"mappings":"AAAA,OAAO,qCAAqC,CAAC","sourcesContent":["import \"../../sap/ui/core/date/Gregorian.js\";\n"]}
@@ -1 +1,2 @@
1
1
  import "../../sap/ui/core/date/Islamic.js";
2
+ //# sourceMappingURL=Islamic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Islamic.js","sourceRoot":"","sources":["../../../src/features/calendar/Islamic.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC","sourcesContent":["import \"../../sap/ui/core/date/Islamic.js\";\n"]}
@@ -1 +1,2 @@
1
1
  import "../../sap/ui/core/date/Japanese.js";
2
+ //# sourceMappingURL=Japanese.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Japanese.js","sourceRoot":"","sources":["../../../src/features/calendar/Japanese.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC","sourcesContent":["import \"../../sap/ui/core/date/Japanese.js\";\n"]}
@@ -1 +1,2 @@
1
1
  import "../../sap/ui/core/date/Persian.js";
2
+ //# sourceMappingURL=Persian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Persian.js","sourceRoot":"","sources":["../../../src/features/calendar/Persian.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC","sourcesContent":["import \"../../sap/ui/core/date/Persian.js\";\n"]}