@ui5/webcomponents-localization 0.0.0-aadaf0b2a → 0.0.0-ade0167ac

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 (234) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +1068 -0
  4. package/README.md +37 -6
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/Assets-static.d.ts +1 -0
  7. package/dist/Assets-static.js +3 -0
  8. package/dist/Assets-static.js.map +1 -0
  9. package/dist/Assets.d.ts +1 -0
  10. package/dist/Assets.js +2 -1
  11. package/dist/Assets.js.map +1 -0
  12. package/dist/DateFormat.d.ts +6 -0
  13. package/dist/DateFormat.js +6 -2
  14. package/dist/DateFormat.js.map +1 -0
  15. package/dist/LocaleData.d.ts +6 -0
  16. package/dist/LocaleData.js +6 -2
  17. package/dist/LocaleData.js.map +1 -0
  18. package/dist/dates/CalendarDate.d.ts +43 -0
  19. package/dist/dates/CalendarDate.js +171 -181
  20. package/dist/dates/CalendarDate.js.map +1 -0
  21. package/dist/dates/ExtremeDates.d.ts +5 -0
  22. package/dist/dates/ExtremeDates.js +29 -0
  23. package/dist/dates/ExtremeDates.js.map +1 -0
  24. package/dist/dates/UI5Date.d.ts +6 -0
  25. package/dist/dates/UI5Date.js +7 -0
  26. package/dist/dates/UI5Date.js.map +1 -0
  27. package/dist/dates/UniversalDate.d.ts +47 -0
  28. package/dist/dates/UniversalDate.js +5 -0
  29. package/dist/dates/UniversalDate.js.map +1 -0
  30. package/dist/dates/calculateWeekNumber.d.ts +6 -0
  31. package/dist/dates/calculateWeekNumber.js +43 -49
  32. package/dist/dates/calculateWeekNumber.js.map +1 -0
  33. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  34. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  35. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  36. package/dist/dates/getDaysInMonth.d.ts +3 -0
  37. package/dist/dates/getDaysInMonth.js +10 -0
  38. package/dist/dates/getDaysInMonth.js.map +1 -0
  39. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  40. package/dist/dates/getRoundedTimestamp.js +15 -0
  41. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  42. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  43. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  44. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  45. package/dist/dates/modifyDateBy.d.ts +14 -0
  46. package/dist/dates/modifyDateBy.js +55 -0
  47. package/dist/dates/modifyDateBy.js.map +1 -0
  48. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  49. package/dist/dates/transformDateToSecondaryType.js +18 -0
  50. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  51. package/dist/features/calendar/Buddhist.js +1 -0
  52. package/dist/features/calendar/Buddhist.js.map +1 -0
  53. package/dist/features/calendar/Gregorian.js +1 -0
  54. package/dist/features/calendar/Gregorian.js.map +1 -0
  55. package/dist/features/calendar/Islamic.js +1 -0
  56. package/dist/features/calendar/Islamic.js.map +1 -0
  57. package/dist/features/calendar/Japanese.js +1 -0
  58. package/dist/features/calendar/Japanese.js.map +1 -0
  59. package/dist/features/calendar/Persian.js +1 -0
  60. package/dist/features/calendar/Persian.js.map +1 -0
  61. package/dist/generated/assets/cldr/ar.json +5571 -5904
  62. package/dist/generated/assets/cldr/ar_EG.json +5571 -5904
  63. package/dist/generated/assets/cldr/ar_SA.json +5570 -5904
  64. package/dist/generated/assets/cldr/bg.json +4491 -4977
  65. package/dist/generated/assets/cldr/ca.json +4478 -4994
  66. package/dist/generated/assets/cldr/cnr.json +4667 -0
  67. package/dist/generated/assets/cldr/cs.json +5067 -5496
  68. package/dist/generated/assets/cldr/cy.json +5481 -0
  69. package/dist/generated/assets/cldr/da.json +4371 -4886
  70. package/dist/generated/assets/cldr/de.json +4420 -4914
  71. package/dist/generated/assets/cldr/de_AT.json +4421 -4915
  72. package/dist/generated/assets/cldr/de_CH.json +4419 -4913
  73. package/dist/generated/assets/cldr/el.json +4309 -4881
  74. package/dist/generated/assets/cldr/el_CY.json +4309 -4881
  75. package/dist/generated/assets/cldr/en.json +4342 -4968
  76. package/dist/generated/assets/cldr/en_AU.json +4382 -4960
  77. package/dist/generated/assets/cldr/en_GB.json +4373 -4969
  78. package/dist/generated/assets/cldr/en_HK.json +4382 -4975
  79. package/dist/generated/assets/cldr/en_IE.json +4373 -4969
  80. package/dist/generated/assets/cldr/en_IN.json +4378 -4970
  81. package/dist/generated/assets/cldr/en_NZ.json +4373 -4969
  82. package/dist/generated/assets/cldr/en_PG.json +4374 -4970
  83. package/dist/generated/assets/cldr/en_SG.json +4378 -4971
  84. package/dist/generated/assets/cldr/en_ZA.json +4374 -4970
  85. package/dist/generated/assets/cldr/es.json +4584 -4910
  86. package/dist/generated/assets/cldr/es_AR.json +4587 -4912
  87. package/dist/generated/assets/cldr/es_BO.json +4586 -4911
  88. package/dist/generated/assets/cldr/es_CL.json +4479 -4912
  89. package/dist/generated/assets/cldr/es_CO.json +4479 -4911
  90. package/dist/generated/assets/cldr/es_MX.json +4588 -4913
  91. package/dist/generated/assets/cldr/es_PE.json +4370 -4911
  92. package/dist/generated/assets/cldr/es_UY.json +4372 -4913
  93. package/dist/generated/assets/cldr/es_VE.json +4371 -4912
  94. package/dist/generated/assets/cldr/et.json +4373 -4965
  95. package/dist/generated/assets/cldr/fa.json +4429 -4881
  96. package/dist/generated/assets/cldr/fi.json +4514 -5006
  97. package/dist/generated/assets/cldr/fr.json +4383 -4977
  98. package/dist/generated/assets/cldr/fr_BE.json +4383 -4977
  99. package/dist/generated/assets/cldr/fr_CA.json +4377 -4971
  100. package/dist/generated/assets/cldr/fr_CH.json +4401 -4995
  101. package/dist/generated/assets/cldr/fr_LU.json +4383 -4977
  102. package/dist/generated/assets/cldr/he.json +4980 -5376
  103. package/dist/generated/assets/cldr/hi.json +4345 -4827
  104. package/dist/generated/assets/cldr/hr.json +4640 -4917
  105. package/dist/generated/assets/cldr/hu.json +4415 -4854
  106. package/dist/generated/assets/cldr/id.json +4132 -4656
  107. package/dist/generated/assets/cldr/it.json +4355 -4948
  108. package/dist/generated/assets/cldr/it_CH.json +4355 -4948
  109. package/dist/generated/assets/cldr/ja.json +4251 -4828
  110. package/dist/generated/assets/cldr/kk.json +4503 -4723
  111. package/dist/generated/assets/cldr/ko.json +4210 -4736
  112. package/dist/generated/assets/cldr/lt.json +4939 -5479
  113. package/dist/generated/assets/cldr/lv.json +4651 -5110
  114. package/dist/generated/assets/cldr/mk.json +4408 -0
  115. package/dist/generated/assets/cldr/ms.json +4093 -4513
  116. package/dist/generated/assets/cldr/nb.json +4403 -4975
  117. package/dist/generated/assets/cldr/nl.json +4542 -4882
  118. package/dist/generated/assets/cldr/nl_BE.json +4542 -4882
  119. package/dist/generated/assets/cldr/pl.json +4978 -5174
  120. package/dist/generated/assets/cldr/pt.json +4597 -4803
  121. package/dist/generated/assets/cldr/pt_PT.json +4648 -4938
  122. package/dist/generated/assets/cldr/ro.json +4633 -5088
  123. package/dist/generated/assets/cldr/ru.json +4947 -5405
  124. package/dist/generated/assets/cldr/ru_UA.json +4947 -5405
  125. package/dist/generated/assets/cldr/sk.json +4980 -5368
  126. package/dist/generated/assets/cldr/sl.json +4948 -5338
  127. package/dist/generated/assets/cldr/sr.json +4737 -5124
  128. package/dist/generated/assets/cldr/sr_Latn.json +4724 -0
  129. package/dist/generated/assets/cldr/sv.json +4406 -5009
  130. package/dist/generated/assets/cldr/th.json +4234 -4795
  131. package/dist/generated/assets/cldr/tr.json +4451 -4977
  132. package/dist/generated/assets/cldr/uk.json +4908 -5351
  133. package/dist/generated/assets/cldr/vi.json +4094 -4671
  134. package/dist/generated/assets/cldr/zh_CN.json +4124 -4630
  135. package/dist/generated/assets/cldr/zh_HK.json +4132 -4638
  136. package/dist/generated/assets/cldr/zh_SG.json +4132 -4638
  137. package/dist/generated/assets/cldr/zh_TW.json +4155 -4726
  138. package/dist/generated/json-imports/LocaleData-static.d.ts +1 -0
  139. package/dist/generated/json-imports/LocaleData-static.js +90 -0
  140. package/dist/generated/json-imports/LocaleData-static.js.map +1 -0
  141. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  142. package/dist/generated/json-imports/LocaleData.js +93 -0
  143. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  144. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  145. package/dist/getCachedLocaleDataInstance.js +10 -0
  146. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  147. package/dist/locale/getLocaleData.d.ts +11 -0
  148. package/dist/locale/getLocaleData.js +13 -17
  149. package/dist/locale/getLocaleData.js.map +1 -0
  150. package/dist/sap/base/Event.js +59 -0
  151. package/dist/sap/base/Eventing.js +146 -0
  152. package/dist/sap/base/Log.js +2 -248
  153. package/dist/sap/base/assert.js +31 -9
  154. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  155. package/dist/sap/base/config.js +17 -0
  156. package/dist/sap/base/i18n/Formatting.js +1133 -0
  157. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  158. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  159. package/dist/sap/base/i18n/Localization.js +12 -0
  160. package/dist/sap/base/i18n/Localization.js.map +1 -0
  161. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  162. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  163. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  164. package/dist/sap/base/strings/camelize.js +30 -0
  165. package/dist/sap/base/strings/formatMessage.js +88 -15
  166. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  167. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  168. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  169. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  170. package/dist/sap/base/util/ObjectPath.js +4 -33
  171. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  172. package/dist/sap/base/util/Version.js +157 -0
  173. package/dist/sap/base/util/_merge.js +83 -26
  174. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  175. package/dist/sap/base/util/deepClone.js +102 -0
  176. package/dist/sap/base/util/deepEqual.js +75 -55
  177. package/dist/sap/base/util/extend.js +58 -7
  178. package/dist/sap/base/util/isEmptyObject.js +34 -0
  179. package/dist/sap/base/util/isPlainObject.js +35 -1
  180. package/dist/sap/base/util/now.js +24 -3
  181. package/dist/sap/base/util/resolveReference.js +3 -0
  182. package/dist/sap/base/util/uid.js +27 -0
  183. package/dist/sap/ui/base/DataType.js +657 -0
  184. package/dist/sap/ui/base/Interface.js +50 -6
  185. package/dist/sap/ui/base/Metadata.js +435 -173
  186. package/dist/sap/ui/base/Object.js +287 -27
  187. package/dist/sap/ui/core/CalendarType.js +24 -8
  188. package/dist/sap/ui/core/Configuration.d.ts +18 -0
  189. package/dist/sap/ui/core/Configuration.js +23 -0
  190. package/dist/sap/ui/core/Configuration.js.map +1 -0
  191. package/dist/sap/ui/core/Core.d.ts +27 -0
  192. package/dist/sap/ui/core/Core.js +7 -32
  193. package/dist/sap/ui/core/Core.js.map +1 -0
  194. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  195. package/dist/sap/ui/core/FormatSettings.js +14 -0
  196. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  197. package/dist/sap/ui/core/Locale.js +190 -116
  198. package/dist/sap/ui/core/LocaleData.js +2668 -2679
  199. package/dist/sap/ui/core/Supportability.js +5 -0
  200. package/dist/sap/ui/core/Theming.js +539 -0
  201. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  202. package/dist/sap/ui/core/date/CalendarUtils.js +65 -0
  203. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  204. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  205. package/dist/sap/ui/core/date/Islamic.js +298 -185
  206. package/dist/sap/ui/core/date/Japanese.js +212 -117
  207. package/dist/sap/ui/core/date/Persian.js +324 -195
  208. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  209. package/dist/sap/ui/core/date/UniversalDate.js +1251 -209
  210. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  211. package/dist/sap/ui/core/format/DateFormat.js +3163 -1781
  212. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -0
  213. package/package-scripts.cjs +28 -0
  214. package/package.json +21 -13
  215. package/tsconfig.json +24 -0
  216. package/used-modules.txt +35 -8
  217. package/dist/json-imports/LocaleData.js +0 -171
  218. package/dist/sap/ui/Device.js +0 -5
  219. package/package-scripts.js +0 -30
  220. package/src/Assets.js +0 -2
  221. package/src/DateFormat.js +0 -3
  222. package/src/LocaleData.js +0 -3
  223. package/src/dates/CalendarDate.js +0 -203
  224. package/src/dates/calculateWeekNumber.js +0 -51
  225. package/src/json-imports/LocaleData.js +0 -171
  226. package/src/locale/getLocaleData.js +0 -27
  227. package/src/sap/base/util/LoaderExtensions.js +0 -7
  228. package/src/sap/ui/core/Core.js +0 -38
  229. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  230. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  231. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  232. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  233. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  234. /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
-
3
- 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;
1
+ import UniversalDate from "./UniversalDate.js";
2
+ const calculateWeekNumber = (confFirstDayOfWeek, oDate, iYear, oLocale, oLocaleData, calendarType) => {
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 = UniversalDate.getInstance(oDate, calendarType);
16
+ oJanFirst.setUTCFullYear(iYear, 0, 1);
17
+ iWeekDay = oJanFirst.getUTCDay();
18
+ // get the date for the same weekday like jan 1.
19
+ const oCheckDate = UniversalDate.getInstance(oDate, calendarType);
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 = UniversalDate.getInstance(oDate, calendarType);
28
+ oThursday.setUTCDate(oThursday.getUTCDate() - iFirstDayOfWeek);
29
+ iWeekDay = oThursday.getUTCDay();
30
+ oThursday.setUTCDate(oThursday.getUTCDate() - iWeekDay + 4);
31
+ const oFirstDayOfYear = UniversalDate.getInstance(new Date(oThursday.getTime()), calendarType);
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 = UniversalDate.getInstance(new Date(oFirstDayOfYear.getTime()), calendarType);
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":"AAEA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAI/C,MAAM,mBAAmB,GAAG,CAAC,kBAAsC,EAAE,KAAqB,EAAE,KAAa,EAAE,OAAe,EAAE,WAAuB,EAAE,YAA0B,EAAE,EAAE;IAClL,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,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACjE,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,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAClE,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,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACjE,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,aAAa,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;QAC/F,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,aAAa,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;QACpG,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 CalendarType from \"@ui5/webcomponents-base/dist/types/CalendarType.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, calendarType: CalendarType) => {\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 = UniversalDate.getInstance(oDate, calendarType);\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 = UniversalDate.getInstance(oDate, calendarType);\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 = UniversalDate.getInstance(oDate, calendarType);\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 = UniversalDate.getInstance(new Date(oThursday.getTime()), calendarType);\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 = UniversalDate.getInstance(new Date(oFirstDayOfYear.getTime()), calendarType);\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;
@@ -0,0 +1,15 @@
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
+ 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;
13
+ };
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;
@@ -0,0 +1,9 @@
1
+ import CalendarDate from "./CalendarDate.js";
2
+ import UI5Date from "./UI5Date.js";
3
+ /**
4
+ * Returns a UTC timestamp representing today
5
+ * @public
6
+ */
7
+ const getTodayUTCTimestamp = (primaryCalendarType) => CalendarDate.fromLocalJSDate(UI5Date.getInstance(), primaryCalendarType).valueOf() / 1000;
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,14 @@
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 preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
10
+ * @param minDate minimum date to enforce
11
+ * @param maxDate maximum date to enforce
12
+ */
13
+ declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, preserveDate?: boolean, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
14
+ export default modifyDateBy;
@@ -0,0 +1,55 @@
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 preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
10
+ * @param minDate minimum date to enforce
11
+ * @param maxDate maximum date to enforce
12
+ */
13
+ const modifyDateBy = (date, amount, unit, preserveDate = true, minDate, maxDate) => {
14
+ const newDate = new CalendarDate(date);
15
+ switch (unit) {
16
+ case "day":
17
+ newDate.setDate(date.getDate() + amount);
18
+ break;
19
+ case "month":
20
+ if (preserveDate) {
21
+ newDate.setMonth(date.getMonth() + amount);
22
+ const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
23
+ const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
24
+ if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
25
+ newDate.setDate(0);
26
+ }
27
+ }
28
+ else {
29
+ if (amount === 1) {
30
+ newDate.setMonth(newDate.getMonth() + 1, 1);
31
+ }
32
+ if (amount === -1) {
33
+ newDate.setDate(0);
34
+ }
35
+ }
36
+ break;
37
+ case "year":
38
+ newDate.setYear(date.getYear() + amount);
39
+ if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
40
+ newDate.setDate(0); // Select the last day of the month
41
+ }
42
+ break;
43
+ default:
44
+ break;
45
+ }
46
+ if (minDate && newDate.isBefore(minDate)) {
47
+ return new CalendarDate(minDate);
48
+ }
49
+ if (maxDate && newDate.isAfter(maxDate)) {
50
+ return new CalendarDate(maxDate);
51
+ }
52
+ return newDate;
53
+ };
54
+ export default modifyDateBy;
55
+ //# 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;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,YAAY,GAAG,IAAI,EAAE,OAAsB,EAAE,OAAsB,EAAE,EAAE;IAC9I,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAEvC,QAAQ,IAAI,EAAE;QACd,KAAK,KAAK;YACT,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;YACzC,MAAM;QACP,KAAK,OAAO;YACX,IAAI,YAAY,EAAE;gBACjB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,CAAC;gBAC3C,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,yCAAyC;gBACzH,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,sCAAsC;gBACrH,IAAI,cAAc,IAAI,YAAY,EAAE,EAAE,+DAA+D;oBACpG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACnB;aACD;iBAAM;gBACN,IAAI,MAAM,KAAK,CAAC,EAAE;oBACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC5C;gBACD,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;oBAClB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACnB;aACD;YACD,MAAM;QACP,KAAK,MAAM;YACV,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;YACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,kCAAkC;gBAC/E,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;aACvD;YACD,MAAM;QACP;YACC,MAAM;KACN;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACzC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACxC,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 preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)\n * @param minDate minimum date to enforce\n * @param maxDate maximum date to enforce\n */\nconst modifyDateBy = (date: CalendarDate, amount: number, unit: string, preserveDate = true, minDate?: CalendarDate, maxDate?: CalendarDate) => {\n\tconst newDate = new CalendarDate(date);\n\n\tswitch (unit) {\n\tcase \"day\":\n\t\tnewDate.setDate(date.getDate() + amount);\n\t\tbreak;\n\tcase \"month\":\n\t\tif (preserveDate) {\n\t\t\tnewDate.setMonth(date.getMonth() + amount);\n\t\t\tconst stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month\n\t\t\tconst monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month\n\t\t\tif (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t} else {\n\t\t\tif (amount === 1) {\n\t\t\t\tnewDate.setMonth(newDate.getMonth() + 1, 1);\n\t\t\t}\n\t\t\tif (amount === -1) {\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase \"year\":\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\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (minDate && newDate.isBefore(minDate)) {\n\t\treturn new CalendarDate(minDate);\n\t}\n\n\tif (maxDate && newDate.isAfter(maxDate)) {\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"]}