@ui5/webcomponents-localization 0.0.0-db2be6526 → 0.0.0-db622d8a8

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 (191) hide show
  1. package/.eslintignore +1 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +420 -0
  4. package/README.md +5 -6
  5. package/{src/Assets-static.js → dist/Assets-static.d.ts} +0 -1
  6. package/dist/Assets-static.js +1 -0
  7. package/dist/Assets-static.js.map +1 -0
  8. package/dist/Assets.d.ts +1 -0
  9. package/dist/Assets.js +1 -0
  10. package/dist/Assets.js.map +1 -0
  11. package/dist/DateFormat.d.ts +6 -0
  12. package/dist/DateFormat.js +6 -2
  13. package/dist/DateFormat.js.map +1 -0
  14. package/dist/LocaleData.d.ts +6 -0
  15. package/dist/LocaleData.js +6 -2
  16. package/dist/LocaleData.js.map +1 -0
  17. package/dist/dates/CalendarDate.d.ts +43 -0
  18. package/dist/dates/CalendarDate.js +171 -201
  19. package/dist/dates/CalendarDate.js.map +1 -0
  20. package/dist/dates/ExtremeDates.d.ts +5 -0
  21. package/dist/dates/ExtremeDates.js +25 -35
  22. package/dist/dates/ExtremeDates.js.map +1 -0
  23. package/dist/dates/UI5Date.d.ts +6 -0
  24. package/dist/dates/UI5Date.js +7 -0
  25. package/dist/dates/UI5Date.js.map +1 -0
  26. package/dist/dates/UniversalDate.d.ts +47 -0
  27. package/dist/dates/UniversalDate.js +5 -0
  28. package/dist/dates/UniversalDate.js.map +1 -0
  29. package/dist/dates/calculateWeekNumber.d.ts +5 -0
  30. package/dist/dates/calculateWeekNumber.js +42 -48
  31. package/dist/dates/calculateWeekNumber.js.map +1 -0
  32. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  33. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  34. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  35. package/dist/dates/getDaysInMonth.d.ts +3 -0
  36. package/dist/dates/getDaysInMonth.js +10 -0
  37. package/dist/dates/getDaysInMonth.js.map +1 -0
  38. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  39. package/dist/dates/getRoundedTimestamp.js +10 -9
  40. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  41. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  42. package/dist/dates/getTodayUTCTimestamp.js +3 -3
  43. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  44. package/dist/dates/modifyDateBy.d.ts +13 -0
  45. package/dist/dates/modifyDateBy.js +27 -29
  46. package/dist/dates/modifyDateBy.js.map +1 -0
  47. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  48. package/dist/dates/transformDateToSecondaryType.js +18 -0
  49. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  50. package/dist/features/calendar/Buddhist.js +1 -0
  51. package/dist/features/calendar/Buddhist.js.map +1 -0
  52. package/dist/features/calendar/Gregorian.js +1 -0
  53. package/dist/features/calendar/Gregorian.js.map +1 -0
  54. package/dist/features/calendar/Islamic.js +1 -0
  55. package/dist/features/calendar/Islamic.js.map +1 -0
  56. package/dist/features/calendar/Japanese.js +1 -0
  57. package/dist/features/calendar/Japanese.js.map +1 -0
  58. package/dist/features/calendar/Persian.js +1 -0
  59. package/dist/features/calendar/Persian.js.map +1 -0
  60. package/dist/generated/assets/cldr/ar.json +5531 -5906
  61. package/dist/generated/assets/cldr/ar_EG.json +5531 -5906
  62. package/dist/generated/assets/cldr/ar_SA.json +5530 -5906
  63. package/dist/generated/assets/cldr/bg.json +4452 -4979
  64. package/dist/generated/assets/cldr/ca.json +4440 -4996
  65. package/dist/generated/assets/cldr/cs.json +4960 -5498
  66. package/dist/generated/assets/cldr/cy.json +5211 -5884
  67. package/dist/generated/assets/cldr/da.json +4308 -4888
  68. package/dist/generated/assets/cldr/de.json +4313 -4916
  69. package/dist/generated/assets/cldr/de_AT.json +4314 -4917
  70. package/dist/generated/assets/cldr/de_CH.json +4312 -4915
  71. package/dist/generated/assets/cldr/el.json +4281 -4883
  72. package/dist/generated/assets/cldr/el_CY.json +4281 -4883
  73. package/dist/generated/assets/cldr/en.json +4316 -4971
  74. package/dist/generated/assets/cldr/en_AU.json +4319 -4962
  75. package/dist/generated/assets/cldr/en_GB.json +4329 -4971
  76. package/dist/generated/assets/cldr/en_HK.json +4337 -4977
  77. package/dist/generated/assets/cldr/en_IE.json +4328 -4971
  78. package/dist/generated/assets/cldr/en_IN.json +4333 -4972
  79. package/dist/generated/assets/cldr/en_NZ.json +4328 -4971
  80. package/dist/generated/assets/cldr/en_PG.json +4329 -4972
  81. package/dist/generated/assets/cldr/en_SG.json +4333 -4973
  82. package/dist/generated/assets/cldr/en_ZA.json +4329 -4972
  83. package/dist/generated/assets/cldr/es.json +4331 -4912
  84. package/dist/generated/assets/cldr/es_AR.json +4334 -4914
  85. package/dist/generated/assets/cldr/es_BO.json +4333 -4913
  86. package/dist/generated/assets/cldr/es_CL.json +4334 -4914
  87. package/dist/generated/assets/cldr/es_CO.json +4333 -4913
  88. package/dist/generated/assets/cldr/es_MX.json +4335 -4915
  89. package/dist/generated/assets/cldr/es_PE.json +4333 -4913
  90. package/dist/generated/assets/cldr/es_UY.json +4335 -4915
  91. package/dist/generated/assets/cldr/es_VE.json +4334 -4914
  92. package/dist/generated/assets/cldr/et.json +4340 -4967
  93. package/dist/generated/assets/cldr/fa.json +4367 -4883
  94. package/dist/generated/assets/cldr/fi.json +4463 -5008
  95. package/dist/generated/assets/cldr/fr.json +4357 -4979
  96. package/dist/generated/assets/cldr/fr_BE.json +4357 -4979
  97. package/dist/generated/assets/cldr/fr_CA.json +4351 -4973
  98. package/dist/generated/assets/cldr/fr_CH.json +4375 -4997
  99. package/dist/generated/assets/cldr/fr_LU.json +4357 -4979
  100. package/dist/generated/assets/cldr/he.json +4869 -5378
  101. package/dist/generated/assets/cldr/hi.json +4295 -4829
  102. package/dist/generated/assets/cldr/hr.json +4583 -4919
  103. package/dist/generated/assets/cldr/hu.json +4364 -4856
  104. package/dist/generated/assets/cldr/id.json +4060 -4658
  105. package/dist/generated/assets/cldr/it.json +4299 -4950
  106. package/dist/generated/assets/cldr/it_CH.json +4299 -4950
  107. package/dist/generated/assets/cldr/ja.json +4211 -4830
  108. package/dist/generated/assets/cldr/kk.json +4339 -4725
  109. package/dist/generated/assets/cldr/ko.json +4189 -4738
  110. package/dist/generated/assets/cldr/lt.json +4850 -5481
  111. package/dist/generated/assets/cldr/lv.json +4587 -5112
  112. package/dist/generated/assets/cldr/ms.json +4021 -4515
  113. package/dist/generated/assets/cldr/nb.json +4335 -4977
  114. package/dist/generated/assets/cldr/nl.json +4294 -4884
  115. package/dist/generated/assets/cldr/nl_BE.json +4294 -4884
  116. package/dist/generated/assets/cldr/pl.json +4667 -5176
  117. package/dist/generated/assets/cldr/pt.json +4235 -4805
  118. package/dist/generated/assets/cldr/pt_PT.json +4372 -4940
  119. package/dist/generated/assets/cldr/ro.json +4563 -5090
  120. package/dist/generated/assets/cldr/ru.json +4909 -5407
  121. package/dist/generated/assets/cldr/ru_UA.json +4909 -5407
  122. package/dist/generated/assets/cldr/sk.json +4939 -5370
  123. package/dist/generated/assets/cldr/sl.json +4910 -5340
  124. package/dist/generated/assets/cldr/sr.json +4585 -5126
  125. package/dist/generated/assets/cldr/sr_Latn.json +4574 -5127
  126. package/dist/generated/assets/cldr/sv.json +4362 -5011
  127. package/dist/generated/assets/cldr/th.json +4214 -4797
  128. package/dist/generated/assets/cldr/tr.json +4400 -4979
  129. package/dist/generated/assets/cldr/uk.json +4858 -5353
  130. package/dist/generated/assets/cldr/vi.json +4070 -4673
  131. package/dist/generated/assets/cldr/zh_CN.json +4100 -4632
  132. package/dist/generated/assets/cldr/zh_HK.json +4108 -4640
  133. package/dist/generated/assets/cldr/zh_SG.json +4108 -4640
  134. package/dist/generated/assets/cldr/zh_TW.json +4131 -4728
  135. package/dist/generated/json-imports/LocaleData-static.js +2 -1
  136. package/dist/generated/json-imports/LocaleData.js +2 -1
  137. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  138. package/dist/getCachedLocaleDataInstance.js +6 -9
  139. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  140. package/dist/locale/getLocaleData.d.ts +11 -0
  141. package/dist/locale/getLocaleData.js +13 -17
  142. package/dist/locale/getLocaleData.js.map +1 -0
  143. package/dist/sap/base/Log.js +28 -29
  144. package/dist/sap/base/assert.js +5 -6
  145. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  146. package/dist/sap/base/util/LoaderExtensions.js +9 -12
  147. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  148. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  149. package/dist/sap/ui/core/Configuration.js +21 -0
  150. package/dist/sap/ui/core/Configuration.js.map +1 -0
  151. package/dist/sap/ui/core/Core.d.ts +26 -0
  152. package/dist/sap/ui/core/Core.js +7 -32
  153. package/dist/sap/ui/core/Core.js.map +1 -0
  154. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  155. package/dist/sap/ui/core/FormatSettings.js +14 -0
  156. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  157. package/dist/sap/ui/core/Locale.js +13 -0
  158. package/dist/sap/ui/core/LocaleData.js +180 -25
  159. package/dist/sap/ui/core/date/Buddhist.js +0 -6
  160. package/dist/sap/ui/core/date/CalendarUtils.js +36 -0
  161. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +7 -0
  162. package/dist/sap/ui/core/date/Islamic.js +3 -3
  163. package/dist/sap/ui/core/date/Japanese.js +4 -4
  164. package/dist/sap/ui/core/date/UI5Date.js +305 -0
  165. package/dist/sap/ui/core/date/UniversalDate.js +84 -26
  166. package/dist/sap/ui/core/format/DateFormat.js +786 -477
  167. package/dist/sap/ui/core/format/TimezoneUtil.js +89 -0
  168. package/{package-scripts.js → package-scripts.cjs} +7 -10
  169. package/package.json +7 -5
  170. package/tsconfig.json +14 -0
  171. package/used-modules.txt +5 -1
  172. package/hash.txt +0 -1
  173. package/src/Assets.js +0 -2
  174. package/src/DateFormat.js +0 -3
  175. package/src/LocaleData.js +0 -3
  176. package/src/dates/CalendarDate.js +0 -223
  177. package/src/dates/ExtremeDates.js +0 -39
  178. package/src/dates/calculateWeekNumber.js +0 -51
  179. package/src/dates/getRoundedTimestamp.js +0 -14
  180. package/src/dates/getTodayUTCTimestamp.js +0 -9
  181. package/src/dates/modifyDateBy.js +0 -42
  182. package/src/getCachedLocaleDataInstance.js +0 -13
  183. package/src/locale/getLocaleData.js +0 -27
  184. package/src/sap/base/util/LoaderExtensions.js +0 -17
  185. package/src/sap/ui/core/Core.js +0 -38
  186. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  187. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  188. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  189. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  190. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  191. /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;AAI/C,MAAM,mBAAmB,GAAG,CAAC,kBAAsC,EAAE,KAAqB,EAAE,KAAa,EAAE,OAAe,EAAE,WAAuB,EAAE,EAAE;IACtJ,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\";\nimport type UI5Date from \"./UI5Date.js\";\n\nconst calculateWeekNumber = (confFirstDayOfWeek: number | undefined, oDate: Date | UI5Date, 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,YAAgC,EAAE,EAAE;IACnH,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,15 @@
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
+ // no need to replace with UI5Date, as we don't use any non-UTC functions
9
+ millisecondsUTC = new Date().getTime();
10
+ }
11
+ const rounded = millisecondsUTC - (millisecondsUTC % (24 * 60 * 60 * 1000));
12
+ return rounded / 1000;
12
13
  };
13
-
14
14
  export default getRoundedTimestamp;
15
+ //# 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,yEAAyE;QACzE,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\t// no need to replace with UI5Date, as we don't use any non-UTC functions\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,9 @@
1
1
  import CalendarDate from "./CalendarDate.js";
2
-
2
+ import UI5Date from "./UI5Date.js";
3
3
  /**
4
4
  * Returns a UTC timestamp representing today
5
5
  * @public
6
6
  */
7
- const getTodayUTCTimestamp = primaryCalendarType => CalendarDate.fromLocalJSDate(new Date(), primaryCalendarType).valueOf() / 1000;
8
-
7
+ const getTodayUTCTimestamp = (primaryCalendarType) => CalendarDate.fromLocalJSDate(UI5Date.getInstance(), primaryCalendarType).valueOf() / 1000;
9
8
  export default getTodayUTCTimestamp;
9
+ //# 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;AAC7C,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,mBAAsC,EAAE,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,mBAAmB,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAEnK,eAAe,oBAAoB,CAAC","sourcesContent":["import type CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.js\";\nimport CalendarDate from \"./CalendarDate.js\";\nimport UI5Date from \"./UI5Date.js\";\n\n/**\n * Returns a UTC timestamp representing today\n * @public\n */\nconst getTodayUTCTimestamp = (primaryCalendarType: `${CalendarType}`) => CalendarDate.fromLocalJSDate(UI5Date.getInstance(), 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,18 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ import getDaysInMonth from "./getDaysInMonth.js";
3
+ import UI5Date from "./UI5Date.js";
4
+ const transformDateToSecondaryType = (primaryCalendarType, secondaryCalendarType, timeStamp, hasYearPicker) => {
5
+ let firstDate = CalendarDate.fromLocalJSDate(UI5Date.getInstance(timeStamp * 1000), primaryCalendarType);
6
+ let lastDate = CalendarDate.fromLocalJSDate(UI5Date.getInstance(timeStamp * 1000), primaryCalendarType);
7
+ firstDate.setDate(1);
8
+ if (hasYearPicker) {
9
+ firstDate.setMonth(0);
10
+ lastDate.setMonth(11);
11
+ }
12
+ lastDate.setDate(getDaysInMonth(lastDate));
13
+ firstDate = new CalendarDate(firstDate, secondaryCalendarType);
14
+ lastDate = new CalendarDate(lastDate, secondaryCalendarType);
15
+ return { firstDate, lastDate };
16
+ };
17
+ export default transformDateToSecondaryType;
18
+ //# 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;AACjD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,MAAM,4BAA4B,GAAG,CAAC,mBAAkD,EAAE,qBAAmD,EAAE,SAAiB,EAAE,aAAuB,EAAE,EAAE;IAC5L,IAAI,SAAS,GAAG,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACzG,IAAI,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACxG,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\";\nimport UI5Date from \"./UI5Date.js\";\n\nconst transformDateToSecondaryType = (primaryCalendarType: `${CalendarType}` | undefined, secondaryCalendarType: `${CalendarType}`| undefined, timeStamp: number, hasYearPicker?: boolean) => {\n\tlet firstDate = CalendarDate.fromLocalJSDate(UI5Date.getInstance(timeStamp * 1000), primaryCalendarType);\n\tlet lastDate = CalendarDate.fromLocalJSDate(UI5Date.getInstance(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"]}