@cometchat/chat-uikit-react-native 4.3.23 → 5.0.0-beta.1

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 (1181) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
  7. package/android/src/main/AndroidManifest.xml +0 -6
  8. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +171 -27
  9. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +31 -15
  10. package/ios/CometchatUiKit.mm +25 -25
  11. package/ios/FileManager.m +108 -4
  12. package/ios/SoundPlayer.m +32 -5
  13. package/package.json +13 -29
  14. package/react-native-cometchat-ui-kit.podspec +6 -6
  15. package/src/CometChatConversations/CometChatConversations.tsx +1376 -1263
  16. package/src/CometChatConversations/Skeleton.tsx +143 -0
  17. package/src/CometChatConversations/index.ts +7 -21
  18. package/src/CometChatConversations/resources/index.ts +22 -36
  19. package/src/CometChatConversations/style.ts +237 -62
  20. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +844 -683
  21. package/src/CometChatGroupMembers/Skeleton.tsx +197 -0
  22. package/src/CometChatGroupMembers/index.ts +2 -8
  23. package/src/CometChatGroupMembers/resources/index.ts +3 -14
  24. package/src/CometChatGroupMembers/style.ts +532 -22
  25. package/src/CometChatGroups/CometChatGroups.tsx +417 -562
  26. package/src/CometChatGroups/GroupsStyle.ts +176 -109
  27. package/src/CometChatGroups/Skeleton.tsx +328 -0
  28. package/src/CometChatGroups/index.ts +3 -11
  29. package/src/CometChatGroups/resources/index.ts +17 -24
  30. package/src/CometChatGroups/style.ts +15 -16
  31. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +585 -1044
  32. package/src/CometChatMessageComposer/index.ts +4 -8
  33. package/src/CometChatMessageComposer/resources/index.ts +21 -31
  34. package/src/CometChatMessageComposer/styles.tsx +152 -0
  35. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +315 -422
  36. package/src/CometChatMessageHeader/index.ts +3 -15
  37. package/src/CometChatMessageHeader/listners.ts +50 -26
  38. package/src/CometChatMessageHeader/styles.ts +57 -10
  39. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +350 -295
  40. package/src/CometChatMessageInformation/Skeleton.tsx +143 -0
  41. package/src/CometChatMessageInformation/index.ts +5 -9
  42. package/src/CometChatMessageInformation/resources/index.ts +1 -4
  43. package/src/CometChatMessageInformation/styles.ts +147 -16
  44. package/src/CometChatMessageList/CometChatMessageList.tsx +2344 -2080
  45. package/src/CometChatMessageList/Skeleton.tsx +98 -0
  46. package/src/CometChatMessageList/index.ts +5 -12
  47. package/src/CometChatMessageList/resources/index.ts +13 -20
  48. package/src/CometChatMessageList/style.ts +989 -51
  49. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +208 -0
  50. package/src/CometChatThreadHeader/Header.tsx +47 -0
  51. package/src/CometChatThreadHeader/index.ts +8 -0
  52. package/src/CometChatThreadHeader/resources/index.ts +14 -0
  53. package/src/CometChatThreadHeader/style.ts +70 -0
  54. package/src/CometChatUsers/CometChatUsers.tsx +276 -114
  55. package/src/CometChatUsers/Skeleton.tsx +195 -0
  56. package/src/CometChatUsers/index.ts +3 -11
  57. package/src/CometChatUsers/style.ts +181 -0
  58. package/src/calls/CallEvents.ts +9 -9
  59. package/src/calls/CallUtils.ts +102 -31
  60. package/src/calls/CallingConfiguration.ts +22 -4
  61. package/src/calls/CallingExtension.tsx +43 -40
  62. package/src/calls/CallingExtensionDecorator.tsx +416 -0
  63. package/src/calls/CallingPackage.ts +11 -12
  64. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +121 -52
  65. package/src/calls/CometChatCallBubble/index.ts +8 -13
  66. package/src/calls/CometChatCallBubble/resources/index.ts +1 -8
  67. package/src/calls/CometChatCallBubble/styles.ts +155 -22
  68. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +17 -36
  69. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +319 -323
  70. package/src/calls/CometChatCallButtons/index.ts +9 -11
  71. package/src/calls/CometChatCallButtons/style.ts +34 -12
  72. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +429 -377
  73. package/src/calls/CometChatCallLogs/Skeleton.tsx +143 -0
  74. package/src/calls/CometChatCallLogs/index.ts +4 -15
  75. package/src/calls/CometChatCallLogs/resources/index.ts +20 -31
  76. package/src/calls/CometChatCallLogs/style.ts +169 -22
  77. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +279 -217
  78. package/src/calls/CometChatIncomingCall/index.ts +7 -9
  79. package/src/calls/CometChatIncomingCall/resources/index.ts +3 -12
  80. package/src/calls/CometChatIncomingCall/style.ts +75 -0
  81. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +74 -56
  82. package/src/calls/CometChatOngoingCall/index.ts +3 -7
  83. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +207 -171
  84. package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +31 -31
  85. package/src/calls/CometChatOutgoingCall/index.ts +5 -11
  86. package/src/calls/CometChatOutgoingCall/resources/index.ts +1 -4
  87. package/src/calls/CometChatOutgoingCall/styles.ts +58 -0
  88. package/src/calls/index.ts +14 -88
  89. package/src/calls/resources/index.ts +1 -8
  90. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +72 -96
  91. package/src/extensions/CollaborativeBubble/resources/index.ts +2 -4
  92. package/src/extensions/CollaborativeBubble/style.ts +112 -0
  93. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtension.tsx +21 -35
  94. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +220 -189
  95. package/src/extensions/CollaborativeDocument/index.ts +2 -8
  96. package/src/extensions/CollaborativeDocument/resources/index.ts +4 -6
  97. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtension.tsx +25 -35
  98. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +298 -199
  99. package/src/extensions/CollaborativeWhiteboard/index.ts +2 -8
  100. package/src/extensions/CollaborativeWhiteboard/resources/index.ts +4 -6
  101. package/src/extensions/ExtensionConstants.tsx +3 -4
  102. package/src/extensions/ExtensionModerator.tsx +47 -47
  103. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +187 -116
  104. package/src/extensions/LinkPreview/LinkPreviewExtension.tsx +22 -0
  105. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +94 -0
  106. package/src/extensions/LinkPreview/index.ts +6 -16
  107. package/src/extensions/LinkPreview/resources/index.ts +1 -4
  108. package/src/extensions/LinkPreview/style.ts +100 -0
  109. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +112 -116
  110. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +235 -152
  111. package/src/extensions/MessageTranslation/MessageTranslationExtension.tsx +7 -25
  112. package/src/extensions/MessageTranslation/index.ts +3 -5
  113. package/src/extensions/MessageTranslation/resources/index.ts +2 -3
  114. package/src/extensions/Polls/Header.tsx +56 -21
  115. package/src/extensions/Polls/Polls.tsx +368 -332
  116. package/src/extensions/Polls/PollsBubble.tsx +250 -205
  117. package/src/extensions/Polls/PollsConfigurations.ts +0 -9
  118. package/src/extensions/Polls/PollsDecorator.tsx +148 -77
  119. package/src/extensions/Polls/PollsExtension.tsx +5 -12
  120. package/src/extensions/Polls/index.ts +6 -8
  121. package/src/extensions/Polls/resources/index.ts +6 -12
  122. package/src/extensions/Polls/style.ts +185 -1
  123. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +249 -115
  124. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +167 -0
  125. package/src/extensions/Stickers/CometChatStickerKeyboard/StickerKeyboardConfiguration.ts +2 -6
  126. package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +58 -64
  127. package/src/extensions/Stickers/CometChatStickerKeyboard/index.ts +2 -3
  128. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +67 -41
  129. package/src/extensions/Stickers/StickerConfiguration.ts +5 -9
  130. package/src/extensions/Stickers/StickersBubble.tsx +22 -46
  131. package/src/extensions/Stickers/StickersExtension.ts +5 -6
  132. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +290 -104
  133. package/src/extensions/Stickers/index.ts +7 -9
  134. package/src/extensions/Stickers/resources/index.ts +1 -4
  135. package/src/extensions/Stickers/style.ts +53 -0
  136. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +83 -64
  137. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationExtension.tsx +5 -25
  138. package/src/extensions/ThumbnailGeneration/index.ts +1 -3
  139. package/src/extensions/ThumbnailGeneration/resources/index.ts +1 -4
  140. package/src/extensions/index.ts +11 -50
  141. package/src/index.ts +193 -670
  142. package/src/shared/CometChatUiKit/CometChatUIKit.ts +342 -491
  143. package/src/shared/CometChatUiKit/CometChatUIKitHelper.ts +147 -117
  144. package/src/shared/CometChatUiKit/UIKitSettings.ts +38 -38
  145. package/src/shared/CometChatUiKit/index.ts +2 -6
  146. package/src/shared/assets/images/index.ts +13 -29
  147. package/src/shared/base/BaseStyle.ts +9 -8
  148. package/src/shared/base/BorderStyle.ts +4 -4
  149. package/src/shared/base/FontStyle.ts +25 -3
  150. package/src/shared/base/ShadowStyle.ts +1 -1
  151. package/src/shared/base/Types.ts +16 -22
  152. package/src/shared/base/index.ts +7 -25
  153. package/src/shared/base/vars.ts +5 -5
  154. package/src/shared/constants/UIKitConstants.ts +322 -294
  155. package/src/shared/events/CometChatMessageEvents/index.ts +83 -87
  156. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +260 -238
  157. package/src/shared/events/CometChatUIEventHandler/Listener.ts +412 -377
  158. package/src/shared/events/CometChatUIEvents.ts +15 -16
  159. package/src/shared/events/ListenerInitializer.ts +79 -80
  160. package/src/shared/events/conversations.ts +2 -2
  161. package/src/shared/events/groups.ts +8 -8
  162. package/src/shared/events/index.ts +6 -6
  163. package/src/shared/events/messages.ts +26 -29
  164. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +191 -121
  165. package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +3 -3
  166. package/src/shared/formatters/CometChatMentionsFormatter/index.ts +3 -6
  167. package/src/shared/formatters/CometChatTextFormatter.ts +15 -14
  168. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +127 -131
  169. package/src/shared/formatters/index.ts +7 -8
  170. package/src/shared/framework/ChatConfigurator.ts +3 -4
  171. package/src/shared/framework/DataSource.ts +181 -92
  172. package/src/shared/framework/DataSourceDecorator.tsx +307 -233
  173. package/src/shared/framework/ExtensionsDataSource.tsx +8 -11
  174. package/src/shared/framework/MessageDataSource.tsx +1364 -867
  175. package/src/shared/framework/index.ts +8 -6
  176. package/src/shared/framework/resources/index.ts +37 -57
  177. package/src/shared/helper/Toast.tsx +20 -18
  178. package/src/shared/helper/dateHelper.ts +138 -0
  179. package/src/shared/helper/functions.js +1 -1
  180. package/src/shared/helper/helperFunctions.ts +71 -19
  181. package/src/shared/helper/types/index.ts +49 -15
  182. package/src/shared/helper/useKeyboard.tsx +12 -23
  183. package/src/shared/icons/Icon.tsx +73 -0
  184. package/src/shared/icons/components/ListItemCheck.tsx +18 -0
  185. package/src/shared/icons/components/StickerBase-icon.tsx +16 -0
  186. package/src/shared/icons/components/account-circle-fill.tsx +26 -0
  187. package/src/shared/icons/components/account-circle.tsx +11 -0
  188. package/src/shared/icons/components/activity.tsx +20 -0
  189. package/src/shared/icons/components/add-a-photo-fill.tsx +26 -0
  190. package/src/shared/icons/components/add-a-photo.tsx +11 -0
  191. package/src/shared/icons/components/add-box-fill.tsx +26 -0
  192. package/src/shared/icons/components/add-box.tsx +11 -0
  193. package/src/shared/icons/components/add-call-fill.tsx +26 -0
  194. package/src/shared/icons/components/add-call.tsx +11 -0
  195. package/src/shared/icons/components/add-circle-fill.tsx +11 -0
  196. package/src/shared/icons/components/add-circle.tsx +11 -0
  197. package/src/shared/icons/components/add-comment-fill.tsx +26 -0
  198. package/src/shared/icons/components/add-comment.tsx +11 -0
  199. package/src/shared/icons/components/add-fill.tsx +26 -0
  200. package/src/shared/icons/components/add-reaction-fill.tsx +26 -0
  201. package/src/shared/icons/components/add-reaction.tsx +11 -0
  202. package/src/shared/icons/components/add.tsx +11 -0
  203. package/src/shared/icons/components/ai-conversation-summary-fill.tsx +13 -0
  204. package/src/shared/icons/components/ai-conversation-summary.tsx +13 -0
  205. package/src/shared/icons/components/ai-fill.tsx +11 -0
  206. package/src/shared/icons/components/ai-suggest-reply-fill.tsx +13 -0
  207. package/src/shared/icons/components/ai-suggest-reply.tsx +20 -0
  208. package/src/shared/icons/components/ai.tsx +12 -0
  209. package/src/shared/icons/components/alternate-email-fill.tsx +26 -0
  210. package/src/shared/icons/components/alternate-email.tsx +11 -0
  211. package/src/shared/icons/components/animals-&-nature.tsx +18 -0
  212. package/src/shared/icons/components/archive-fill.tsx +26 -0
  213. package/src/shared/icons/components/archive.tsx +11 -0
  214. package/src/shared/icons/components/arrow-back-fill.tsx +26 -0
  215. package/src/shared/icons/components/arrow-back.tsx +11 -0
  216. package/src/shared/icons/components/arrow-forward-fill.tsx +26 -0
  217. package/src/shared/icons/components/arrow-forward.tsx +11 -0
  218. package/src/shared/icons/components/attach-file-fill.tsx +26 -0
  219. package/src/shared/icons/components/attach-file.tsx +11 -0
  220. package/src/shared/icons/components/audio-file-type.tsx +36 -0
  221. package/src/shared/icons/components/bar-chart-fill.tsx +11 -0
  222. package/src/shared/icons/components/bar-chart.tsx +11 -0
  223. package/src/shared/icons/components/base-icon.tsx +16 -0
  224. package/src/shared/icons/components/bedtime-fill.tsx +26 -0
  225. package/src/shared/icons/components/bedtime.tsx +11 -0
  226. package/src/shared/icons/components/block-fill.tsx +26 -0
  227. package/src/shared/icons/components/block.tsx +11 -0
  228. package/src/shared/icons/components/bookmark-add-fill.tsx +26 -0
  229. package/src/shared/icons/components/bookmark-add.tsx +11 -0
  230. package/src/shared/icons/components/bookmark-fill.tsx +26 -0
  231. package/src/shared/icons/components/bookmark.tsx +11 -0
  232. package/src/shared/icons/components/calendar-add-on-fill.tsx +26 -0
  233. package/src/shared/icons/components/calendar-add-on.tsx +11 -0
  234. package/src/shared/icons/components/calendar-today-fill.tsx +26 -0
  235. package/src/shared/icons/components/calendar-today.tsx +11 -0
  236. package/src/shared/icons/components/call-end-fill.tsx +26 -0
  237. package/src/shared/icons/components/call-end.tsx +11 -0
  238. package/src/shared/icons/components/call-fill.tsx +26 -0
  239. package/src/shared/icons/components/call-log-fill.tsx +26 -0
  240. package/src/shared/icons/components/call-log.tsx +11 -0
  241. package/src/shared/icons/components/call-made-fill.tsx +26 -0
  242. package/src/shared/icons/components/call-made.tsx +11 -0
  243. package/src/shared/icons/components/call-missed-fill.tsx +26 -0
  244. package/src/shared/icons/components/call-missed-outgoing-fill.tsx +26 -0
  245. package/src/shared/icons/components/call-missed-outgoing.tsx +11 -0
  246. package/src/shared/icons/components/call-missed.tsx +11 -0
  247. package/src/shared/icons/components/call-received-fill.tsx +26 -0
  248. package/src/shared/icons/components/call-received.tsx +11 -0
  249. package/src/shared/icons/components/call.tsx +11 -0
  250. package/src/shared/icons/components/cancel-fill.tsx +26 -0
  251. package/src/shared/icons/components/cancel.tsx +11 -0
  252. package/src/shared/icons/components/change-circle-fill.tsx +11 -0
  253. package/src/shared/icons/components/change-circle.tsx +11 -0
  254. package/src/shared/icons/components/chat-bot-fill.tsx +13 -0
  255. package/src/shared/icons/components/chat-bot.tsx +17 -0
  256. package/src/shared/icons/components/chat-fill.tsx +26 -0
  257. package/src/shared/icons/components/chat.tsx +11 -0
  258. package/src/shared/icons/components/check-circle-fill.tsx +11 -0
  259. package/src/shared/icons/components/check-circle.tsx +11 -0
  260. package/src/shared/icons/components/check-fill.tsx +26 -0
  261. package/src/shared/icons/components/check.tsx +11 -0
  262. package/src/shared/icons/components/chevron-left-fill.tsx +26 -0
  263. package/src/shared/icons/components/chevron-left.tsx +11 -0
  264. package/src/shared/icons/components/chevron-right-fill.tsx +26 -0
  265. package/src/shared/icons/components/chevron-right.tsx +11 -0
  266. package/src/shared/icons/components/close-fill.tsx +26 -0
  267. package/src/shared/icons/components/close.tsx +11 -0
  268. package/src/shared/icons/components/collaborative-document-fill.tsx +17 -0
  269. package/src/shared/icons/components/collaborative-document-icon.tsx +11 -0
  270. package/src/shared/icons/components/collaborative-document.tsx +13 -0
  271. package/src/shared/icons/components/collaborative-whiteboard-fill.tsx +15 -0
  272. package/src/shared/icons/components/collaborative-whiteboard-icon.tsx +15 -0
  273. package/src/shared/icons/components/collaborative-whiteboard.tsx +12 -0
  274. package/src/shared/icons/components/content-copy-fill.tsx +26 -0
  275. package/src/shared/icons/components/content-copy.tsx +11 -0
  276. package/src/shared/icons/components/crop-fill.tsx +26 -0
  277. package/src/shared/icons/components/crop.tsx +11 -0
  278. package/src/shared/icons/components/delete-fill.tsx +26 -0
  279. package/src/shared/icons/components/delete.tsx +11 -0
  280. package/src/shared/icons/components/description-fill.tsx +26 -0
  281. package/src/shared/icons/components/description.tsx +11 -0
  282. package/src/shared/icons/components/document-file-type.tsx +38 -0
  283. package/src/shared/icons/components/done-all-fill.tsx +26 -0
  284. package/src/shared/icons/components/done-all.tsx +11 -0
  285. package/src/shared/icons/components/download-fill.tsx +26 -0
  286. package/src/shared/icons/components/download.tsx +11 -0
  287. package/src/shared/icons/components/edit-calendar-fill.tsx +26 -0
  288. package/src/shared/icons/components/edit-calendar.tsx +11 -0
  289. package/src/shared/icons/components/edit-fill.tsx +26 -0
  290. package/src/shared/icons/components/edit-square-fill.tsx +11 -0
  291. package/src/shared/icons/components/edit-square.tsx +11 -0
  292. package/src/shared/icons/components/edit.tsx +11 -0
  293. package/src/shared/icons/components/empty-state.tsx +82 -0
  294. package/src/shared/icons/components/error-fill.tsx +34 -0
  295. package/src/shared/icons/components/error-state.tsx +92 -0
  296. package/src/shared/icons/components/error.tsx +11 -0
  297. package/src/shared/icons/components/event-available-fill.tsx +11 -0
  298. package/src/shared/icons/components/event-available.tsx +11 -0
  299. package/src/shared/icons/components/event-fill.tsx +26 -0
  300. package/src/shared/icons/components/event.tsx +11 -0
  301. package/src/shared/icons/components/favorite-fill.tsx +26 -0
  302. package/src/shared/icons/components/favorite.tsx +11 -0
  303. package/src/shared/icons/components/filter-list-fill.tsx +26 -0
  304. package/src/shared/icons/components/filter-list-off-fill.tsx +26 -0
  305. package/src/shared/icons/components/filter-list-off.tsx +11 -0
  306. package/src/shared/icons/components/filter-list.tsx +11 -0
  307. package/src/shared/icons/components/flags.tsx +13 -0
  308. package/src/shared/icons/components/flip-camera-ios-fill.tsx +26 -0
  309. package/src/shared/icons/components/flip-camera-ios.tsx +11 -0
  310. package/src/shared/icons/components/food-&-drink.tsx +18 -0
  311. package/src/shared/icons/components/forward-fill.tsx +26 -0
  312. package/src/shared/icons/components/forward.tsx +11 -0
  313. package/src/shared/icons/components/gif-fill.tsx +13 -0
  314. package/src/shared/icons/components/gif.tsx +12 -0
  315. package/src/shared/icons/components/graphic-eq-fill.tsx +11 -0
  316. package/src/shared/icons/components/graphic-eq.tsx +11 -0
  317. package/src/shared/icons/components/group-add.tsx +11 -0
  318. package/src/shared/icons/components/group-fill.tsx +26 -0
  319. package/src/shared/icons/components/group.tsx +11 -0
  320. package/src/shared/icons/components/help-fill.tsx +26 -0
  321. package/src/shared/icons/components/help.tsx +11 -0
  322. package/src/shared/icons/components/history-fill.tsx +26 -0
  323. package/src/shared/icons/components/history.tsx +11 -0
  324. package/src/shared/icons/components/image-file-type.tsx +35 -0
  325. package/src/shared/icons/components/incoming-audio-fill.tsx +11 -0
  326. package/src/shared/icons/components/incoming-audio.tsx +13 -0
  327. package/src/shared/icons/components/incoming-video-fill.tsx +28 -0
  328. package/src/shared/icons/components/incoming-video.tsx +15 -0
  329. package/src/shared/icons/components/info-fill.tsx +26 -0
  330. package/src/shared/icons/components/info.tsx +11 -0
  331. package/src/shared/icons/components/keep-fill.tsx +26 -0
  332. package/src/shared/icons/components/keep-off-fill.tsx +26 -0
  333. package/src/shared/icons/components/keep-off.tsx +11 -0
  334. package/src/shared/icons/components/keep.tsx +11 -0
  335. package/src/shared/icons/components/keyboard-arrow-down-fill.tsx +26 -0
  336. package/src/shared/icons/components/keyboard-arrow-down.tsx +11 -0
  337. package/src/shared/icons/components/keyboard-arrow-up-fill.tsx +26 -0
  338. package/src/shared/icons/components/keyboard-arrow-up.tsx +11 -0
  339. package/src/shared/icons/components/keyboard-fill.tsx +26 -0
  340. package/src/shared/icons/components/keyboard.tsx +11 -0
  341. package/src/shared/icons/components/language-fill.tsx +26 -0
  342. package/src/shared/icons/components/language.tsx +11 -0
  343. package/src/shared/icons/components/link-fill.tsx +26 -0
  344. package/src/shared/icons/components/link.tsx +11 -0
  345. package/src/shared/icons/components/loading-fill.tsx +12 -0
  346. package/src/shared/icons/components/loading.tsx +12 -0
  347. package/src/shared/icons/components/location-on-fill.tsx +26 -0
  348. package/src/shared/icons/components/location-on.tsx +11 -0
  349. package/src/shared/icons/components/lock-fill.tsx +26 -0
  350. package/src/shared/icons/components/lock-open-fill.tsx +26 -0
  351. package/src/shared/icons/components/lock-open.tsx +11 -0
  352. package/src/shared/icons/components/lock.tsx +11 -0
  353. package/src/shared/icons/components/logout-fill.tsx +11 -0
  354. package/src/shared/icons/components/logout.tsx +11 -0
  355. package/src/shared/icons/components/mail-fill.tsx +26 -0
  356. package/src/shared/icons/components/mail.tsx +11 -0
  357. package/src/shared/icons/components/mic-fill.tsx +26 -0
  358. package/src/shared/icons/components/mic-off-fill.tsx +26 -0
  359. package/src/shared/icons/components/mic-off.tsx +11 -0
  360. package/src/shared/icons/components/mic.tsx +11 -0
  361. package/src/shared/icons/components/missed-video-call-fill.tsx +26 -0
  362. package/src/shared/icons/components/missed-video-call.tsx +11 -0
  363. package/src/shared/icons/components/mood-fill.tsx +26 -0
  364. package/src/shared/icons/components/mood.tsx +11 -0
  365. package/src/shared/icons/components/more-vert-fill.tsx +26 -0
  366. package/src/shared/icons/components/more-vert.tsx +11 -0
  367. package/src/shared/icons/components/near-me-fill.tsx +11 -0
  368. package/src/shared/icons/components/near-me.tsx +11 -0
  369. package/src/shared/icons/components/no-photography-fill.tsx +26 -0
  370. package/src/shared/icons/components/no-photography.tsx +11 -0
  371. package/src/shared/icons/components/notifications-fill.tsx +26 -0
  372. package/src/shared/icons/components/notifications-off-fill.tsx +26 -0
  373. package/src/shared/icons/components/notifications-off.tsx +11 -0
  374. package/src/shared/icons/components/notifications.tsx +11 -0
  375. package/src/shared/icons/components/objects.tsx +20 -0
  376. package/src/shared/icons/components/outgoing-audio-fill.tsx +15 -0
  377. package/src/shared/icons/components/outgoing-audio.tsx +15 -0
  378. package/src/shared/icons/components/outgoing-video-fill.tsx +28 -0
  379. package/src/shared/icons/components/outgoing-video.tsx +15 -0
  380. package/src/shared/icons/components/pause-fill.tsx +26 -0
  381. package/src/shared/icons/components/pause.tsx +11 -0
  382. package/src/shared/icons/components/pdf-file-type.tsx +36 -0
  383. package/src/shared/icons/components/person-add-fill.tsx +26 -0
  384. package/src/shared/icons/components/person-add.tsx +11 -0
  385. package/src/shared/icons/components/person-fill.tsx +26 -0
  386. package/src/shared/icons/components/person-off.tsx +16 -0
  387. package/src/shared/icons/components/person.tsx +11 -0
  388. package/src/shared/icons/components/phone-in-talk-fill.tsx +26 -0
  389. package/src/shared/icons/components/phone-in-talk.tsx +11 -0
  390. package/src/shared/icons/components/phone-incoming-fill.tsx +11 -0
  391. package/src/shared/icons/components/phone-incoming.tsx +11 -0
  392. package/src/shared/icons/components/phone-missed-fill.tsx +26 -0
  393. package/src/shared/icons/components/phone-missed.tsx +11 -0
  394. package/src/shared/icons/components/phone-outgoing-fill.tsx +15 -0
  395. package/src/shared/icons/components/phone-outgoing.tsx +15 -0
  396. package/src/shared/icons/components/photo-camera-fill.tsx +26 -0
  397. package/src/shared/icons/components/photo-camera.tsx +11 -0
  398. package/src/shared/icons/components/photo-fill.tsx +26 -0
  399. package/src/shared/icons/components/photo.tsx +11 -0
  400. package/src/shared/icons/components/play-arrow-fill.tsx +26 -0
  401. package/src/shared/icons/components/play-arrow.tsx +11 -0
  402. package/src/shared/icons/components/play-circle-fill.tsx +26 -0
  403. package/src/shared/icons/components/play-circle.tsx +11 -0
  404. package/src/shared/icons/components/poll-Icon.tsx +10 -0
  405. package/src/shared/icons/components/poll-fill.tsx +11 -0
  406. package/src/shared/icons/components/poll.tsx +11 -0
  407. package/src/shared/icons/components/presentation-file-type.tsx +38 -0
  408. package/src/shared/icons/components/rearrange-fill.tsx +13 -0
  409. package/src/shared/icons/components/rearrange.tsx +13 -0
  410. package/src/shared/icons/components/refresh-fill.tsx +26 -0
  411. package/src/shared/icons/components/refresh.tsx +11 -0
  412. package/src/shared/icons/components/reply-all-fill.tsx +26 -0
  413. package/src/shared/icons/components/reply-all.tsx +11 -0
  414. package/src/shared/icons/components/reply-fill.tsx +26 -0
  415. package/src/shared/icons/components/reply.tsx +11 -0
  416. package/src/shared/icons/components/retry-fill.tsx +11 -0
  417. package/src/shared/icons/components/retry.tsx +11 -0
  418. package/src/shared/icons/components/schedule-fill.tsx +26 -0
  419. package/src/shared/icons/components/schedule.tsx +11 -0
  420. package/src/shared/icons/components/screen-share-fill.tsx +26 -0
  421. package/src/shared/icons/components/screen-share.tsx +11 -0
  422. package/src/shared/icons/components/search-fill.tsx +26 -0
  423. package/src/shared/icons/components/search.tsx +11 -0
  424. package/src/shared/icons/components/send-fill.tsx +26 -0
  425. package/src/shared/icons/components/send.tsx +11 -0
  426. package/src/shared/icons/components/settings-fill.tsx +26 -0
  427. package/src/shared/icons/components/settings.tsx +11 -0
  428. package/src/shared/icons/components/share-fill.tsx +26 -0
  429. package/src/shared/icons/components/share.tsx +11 -0
  430. package/src/shared/icons/components/shield-fill.tsx +11 -0
  431. package/src/shared/icons/components/shield.tsx +11 -0
  432. package/src/shared/icons/components/smileys-&-people.tsx +18 -0
  433. package/src/shared/icons/components/spreadsheet-file-type.tsx +38 -0
  434. package/src/shared/icons/components/star-fill.tsx +26 -0
  435. package/src/shared/icons/components/star.tsx +11 -0
  436. package/src/shared/icons/components/sticker-fill.tsx +12 -0
  437. package/src/shared/icons/components/sticker.tsx +11 -0
  438. package/src/shared/icons/components/stop-circle-fill.tsx +26 -0
  439. package/src/shared/icons/components/stop-circle.tsx +11 -0
  440. package/src/shared/icons/components/stop-fill.tsx +26 -0
  441. package/src/shared/icons/components/stop-screen-share-fill.tsx +26 -0
  442. package/src/shared/icons/components/stop-screen-share.tsx +11 -0
  443. package/src/shared/icons/components/stop.tsx +11 -0
  444. package/src/shared/icons/components/subdirectory-arrow-left-fill.tsx +26 -0
  445. package/src/shared/icons/components/subdirectory-arrow-left.tsx +11 -0
  446. package/src/shared/icons/components/subdirectory-arrow-right-fill.tsx +26 -0
  447. package/src/shared/icons/components/subdirectory-arrow-right.tsx +11 -0
  448. package/src/shared/icons/components/sunny-fill.tsx +26 -0
  449. package/src/shared/icons/components/sunny.tsx +11 -0
  450. package/src/shared/icons/components/symbols.tsx +15 -0
  451. package/src/shared/icons/components/text-file-type.tsx +35 -0
  452. package/src/shared/icons/components/thumb-down-fill.tsx +26 -0
  453. package/src/shared/icons/components/thumb-down.tsx +11 -0
  454. package/src/shared/icons/components/thumb-up-fill.tsx +26 -0
  455. package/src/shared/icons/components/thumb-up.tsx +11 -0
  456. package/src/shared/icons/components/translate-fill.tsx +11 -0
  457. package/src/shared/icons/components/translate.tsx +11 -0
  458. package/src/shared/icons/components/travel-&-places.tsx +18 -0
  459. package/src/shared/icons/components/unknown-file-type.tsx +38 -0
  460. package/src/shared/icons/components/upload-fill.tsx +11 -0
  461. package/src/shared/icons/components/upload.tsx +11 -0
  462. package/src/shared/icons/components/user-empty-icon.tsx +26 -0
  463. package/src/shared/icons/components/video-call-fill.tsx +26 -0
  464. package/src/shared/icons/components/video-call.tsx +11 -0
  465. package/src/shared/icons/components/video-file-type.tsx +38 -0
  466. package/src/shared/icons/components/videocam-fill.tsx +26 -0
  467. package/src/shared/icons/components/videocam-off-fill.tsx +26 -0
  468. package/src/shared/icons/components/videocam-off.tsx +11 -0
  469. package/src/shared/icons/components/videocam.tsx +11 -0
  470. package/src/shared/icons/components/visibility-off-fill.tsx +11 -0
  471. package/src/shared/icons/components/visibility-off.tsx +11 -0
  472. package/src/shared/icons/components/volume-down-fill.tsx +26 -0
  473. package/src/shared/icons/components/volume-down.tsx +11 -0
  474. package/src/shared/icons/components/volume-mute-fill.tsx +26 -0
  475. package/src/shared/icons/components/volume-mute.tsx +11 -0
  476. package/src/shared/icons/components/volume-off-fill.tsx +26 -0
  477. package/src/shared/icons/components/volume-off.tsx +11 -0
  478. package/src/shared/icons/components/volume-up-fill.tsx +26 -0
  479. package/src/shared/icons/components/volume-up.tsx +11 -0
  480. package/src/shared/icons/components/warning-fill.tsx +26 -0
  481. package/src/shared/icons/components/warning.tsx +11 -0
  482. package/src/shared/icons/components/wifi-fill.tsx +26 -0
  483. package/src/shared/icons/components/wifi.tsx +11 -0
  484. package/src/shared/icons/components/zip-file-type.tsx +38 -0
  485. package/src/shared/icons/components/zoom-in-map-fill.tsx +26 -0
  486. package/src/shared/icons/components/zoom-in-map.tsx +11 -0
  487. package/src/shared/icons/components/zoom-out-map-fill.tsx +26 -0
  488. package/src/shared/icons/components/zoom-out-map.tsx +11 -0
  489. package/src/shared/icons/icon-mapping.tsx +620 -0
  490. package/src/shared/index.ts +114 -333
  491. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +0 -1
  492. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +19 -26
  493. package/src/shared/libs/ImageZoom/helper.ts +11 -27
  494. package/src/shared/libs/ImageZoom/index.tsx +4 -7
  495. package/src/shared/libs/ImageZoom/types/index.ts +7 -17
  496. package/src/shared/libs/VideoPlayer/VideoResizeMode.js +1 -1
  497. package/src/shared/modals/CometChatMessageOption.ts +11 -8
  498. package/src/shared/modals/CometChatMessageTemplate.ts +180 -140
  499. package/src/shared/modals/index.ts +2 -57
  500. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +153 -152
  501. package/src/shared/resources/CometChatLocalize/index.ts +2 -8
  502. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +445 -315
  503. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +445 -316
  504. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +445 -315
  505. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +445 -316
  506. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +444 -316
  507. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +445 -315
  508. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +444 -315
  509. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +445 -316
  510. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +445 -316
  511. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +445 -316
  512. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +445 -316
  513. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +445 -316
  514. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +445 -316
  515. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +444 -316
  516. package/src/shared/resources/CometChatSoundManager/index.ts +1 -2
  517. package/src/shared/resources/index.ts +1 -9
  518. package/src/shared/utils/CometChatMessageHelper/index.ts +16 -14
  519. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +50 -0
  520. package/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +1 -1
  521. package/src/shared/utils/CometChatMessagePreview/index.ts +1 -5
  522. package/src/shared/utils/CometChatMessagePreview/resources/index.ts +1 -4
  523. package/src/shared/utils/CometChatMessagePreview/style.ts +45 -0
  524. package/src/shared/utils/CommonUtils.ts +163 -172
  525. package/src/shared/utils/MessageUtils.tsx +326 -146
  526. package/src/shared/utils/NetworkUtils.tsx +32 -24
  527. package/src/shared/utils/PermissionUtil.ts +30 -30
  528. package/src/shared/utils/conversationUtils.ts +93 -86
  529. package/src/shared/utils/index.ts +4 -25
  530. package/src/shared/views/CometChatAICard/CometChatAICard.tsx +100 -66
  531. package/src/shared/views/CometChatAICard/resources/index.ts +2 -4
  532. package/src/shared/views/CometChatActionSheet/ActionItem.ts +12 -57
  533. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +68 -249
  534. package/src/shared/views/CometChatActionSheet/hooks.ts +5 -3
  535. package/src/shared/views/CometChatActionSheet/index.ts +1 -4
  536. package/src/shared/views/CometChatActionSheet/resources/index.ts +5 -7
  537. package/src/shared/views/CometChatActionSheet/style.ts +2 -41
  538. package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +131 -0
  539. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +211 -189
  540. package/src/shared/views/CometChatAudioBubble/index.ts +10 -10
  541. package/src/shared/views/CometChatAudioBubble/resources/index.ts +2 -7
  542. package/src/shared/views/CometChatAudioBubble/style.ts +203 -27
  543. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +26 -104
  544. package/src/shared/views/CometChatAvatar/index.ts +3 -9
  545. package/src/shared/views/CometChatAvatar/styles.ts +37 -24
  546. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +27 -46
  547. package/src/shared/views/CometChatBadge/index.ts +4 -8
  548. package/src/shared/views/CometChatBadge/styles.ts +29 -16
  549. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +133 -152
  550. package/src/shared/views/CometChatBottomSheet/index.ts +2 -5
  551. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +104 -106
  552. package/src/shared/views/CometChatConfirmDialog/index.ts +2 -9
  553. package/src/shared/views/CometChatConfirmDialog/style.ts +121 -62
  554. package/src/shared/views/CometChatDate/CometChatDate.tsx +23 -157
  555. package/src/shared/views/CometChatDate/index.ts +4 -12
  556. package/src/shared/views/CometChatDate/styles.ts +36 -0
  557. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +48 -0
  558. package/src/shared/views/CometChatDateSeperator/index.ts +6 -0
  559. package/src/shared/views/CometChatDateSeperator/styles.ts +52 -0
  560. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +42 -0
  561. package/src/shared/views/CometChatDeletedBubble/index.ts +5 -0
  562. package/src/shared/views/CometChatDeletedBubble/styles.ts +42 -0
  563. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +284 -205
  564. package/src/shared/views/CometChatEmojiKeyboard/Emoji.ts +1 -1
  565. package/src/shared/views/CometChatEmojiKeyboard/EmojiCategory.ts +1 -1
  566. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +169 -1405
  567. package/src/shared/views/CometChatEmojiKeyboard/index.ts +1 -3
  568. package/src/shared/views/CometChatEmojiKeyboard/resources/index.ts +8 -16
  569. package/src/shared/views/CometChatEmojiKeyboard/style.ts +72 -61
  570. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +203 -173
  571. package/src/shared/views/CometChatFileBubble/index.ts +10 -6
  572. package/src/shared/views/CometChatFileBubble/resources/index.ts +1 -6
  573. package/src/shared/views/CometChatFileBubble/style.ts +120 -47
  574. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +57 -251
  575. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +154 -0
  576. package/src/shared/views/CometChatImageBubble/assets/index.ts +1 -5
  577. package/src/shared/views/CometChatImageBubble/index.ts +7 -9
  578. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +28 -43
  579. package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -1
  580. package/src/shared/views/CometChatImageViewerModal/resources/index.ts +1 -2
  581. package/src/shared/views/CometChatList/CometChatList.tsx +667 -700
  582. package/src/shared/views/CometChatList/Header.tsx +185 -110
  583. package/src/shared/views/CometChatList/index.ts +7 -4
  584. package/src/shared/views/CometChatList/resources/index.ts +4 -13
  585. package/src/shared/views/CometChatList/styles.ts +58 -44
  586. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +132 -259
  587. package/src/shared/views/CometChatListItem/index.ts +3 -15
  588. package/src/shared/views/CometChatListItem/style.ts +25 -29
  589. package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +129 -0
  590. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +115 -0
  591. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +233 -0
  592. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +359 -284
  593. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +83 -0
  594. package/src/shared/views/CometChatMediaRecorder/index.ts +4 -10
  595. package/src/shared/views/CometChatMediaRecorder/style.ts +69 -23
  596. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +111 -124
  597. package/src/shared/views/CometChatMessageBubble/index.ts +2 -5
  598. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +44 -85
  599. package/src/shared/views/CometChatMessageInput/index.ts +10 -3
  600. package/src/shared/views/CometChatMessageInput/styles.ts +2 -2
  601. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +51 -45
  602. package/src/shared/views/CometChatPanel/PanelStyle.tsx +36 -36
  603. package/src/shared/views/CometChatPanel/resources/index.ts +1 -4
  604. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +51 -73
  605. package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +33 -33
  606. package/src/shared/views/CometChatQuickReactions/index.ts +4 -5
  607. package/src/shared/views/CometChatQuickReactions/resources/index.ts +1 -2
  608. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +365 -311
  609. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +152 -64
  610. package/src/shared/views/CometChatReactionList/Skeleton.tsx +143 -0
  611. package/src/shared/views/CometChatReactionList/index.ts +6 -5
  612. package/src/shared/views/CometChatReactionList/resources/index.ts +1 -4
  613. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +103 -171
  614. package/src/shared/views/CometChatReactions/index.ts +7 -14
  615. package/src/shared/views/CometChatReactions/style.ts +193 -41
  616. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +75 -76
  617. package/src/shared/views/CometChatReceipt/index.ts +4 -10
  618. package/src/shared/views/CometChatReceipt/resources/blue-double-tick-icon.png +0 -0
  619. package/src/shared/views/CometChatReceipt/resources/error.png +0 -0
  620. package/src/shared/views/CometChatReceipt/resources/grey-double-tick-icon.png +0 -0
  621. package/src/shared/views/CometChatReceipt/resources/grey-tick-icon.png +0 -0
  622. package/src/shared/views/CometChatReceipt/resources/index.ts +5 -10
  623. package/src/shared/views/CometChatReceipt/resources/sending.png +0 -0
  624. package/src/shared/views/CometChatReceipt/style.ts +50 -9
  625. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +56 -59
  626. package/src/shared/views/CometChatStatusIndicator/index.ts +6 -22
  627. package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
  628. package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
  629. package/src/shared/views/CometChatStatusIndicator/styles.ts +47 -15
  630. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +74 -56
  631. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +185 -0
  632. package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +44 -46
  633. package/src/shared/views/CometChatSuggestionList/index.ts +3 -7
  634. package/src/shared/views/CometChatSuggestionList/style.ts +69 -0
  635. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +46 -101
  636. package/src/shared/views/CometChatTextBubble/index.ts +8 -7
  637. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +166 -0
  638. package/src/shared/views/CometChatTooltipMenu/index.ts +3 -0
  639. package/src/shared/views/CometChatTooltipMenu/styles.ts +24 -0
  640. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +155 -195
  641. package/src/shared/views/CometChatVideoBubble/index.ts +7 -9
  642. package/src/shared/views/CometChatVideoBubble/resources/index.ts +2 -7
  643. package/src/shared/views/CometChatVideoBubble/style.ts +101 -5
  644. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +135 -90
  645. package/src/shared/views/CometChatVideoPlayer/index.tsx +1 -1
  646. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +47 -0
  647. package/src/shared/views/index.ts +72 -214
  648. package/src/theme/CometChatThemeHelper.ts +427 -0
  649. package/src/theme/context.ts +20 -0
  650. package/src/theme/default/color/dark.ts +99 -0
  651. package/src/theme/default/color/light.ts +105 -0
  652. package/src/theme/default/index.ts +242 -0
  653. package/src/theme/default/resources/icons/Base_Icon.png +0 -0
  654. package/src/theme/default/resources/icons/collaborative_document_1x.png +0 -0
  655. package/src/theme/default/resources/icons/collaborative_document_2x.png +0 -0
  656. package/src/theme/default/resources/icons/collaborative_document_3x.png +0 -0
  657. package/src/theme/default/resources/icons/collaborative_whiteboard_1x.png +0 -0
  658. package/src/theme/default/resources/icons/collaborative_whiteboard_2x.png +0 -0
  659. package/src/theme/default/resources/icons/collaborative_whiteboard_3x.png +0 -0
  660. package/src/theme/default/resources/icons/dark_error_icon.png +0 -0
  661. package/src/theme/default/resources/icons/index.ts +19 -0
  662. package/src/theme/default/resources/icons/light_error_icon.png +0 -0
  663. package/src/theme/default/resources/icons/thread_replies.png +0 -0
  664. package/src/theme/default/spacing.ts +86 -0
  665. package/src/theme/default/typography.ts +184 -0
  666. package/src/theme/hook.ts +19 -0
  667. package/src/theme/index.ts +3 -0
  668. package/src/theme/provider.tsx +135 -0
  669. package/src/theme/type.ts +446 -0
  670. package/screenshots/logo.png +0 -0
  671. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -166
  672. package/src/AI/AIAssistBot/AIAssistBotExtension.tsx +0 -22
  673. package/src/AI/AIAssistBot/AIAssistBotStyle.ts +0 -43
  674. package/src/AI/AIAssistBot/AIAssistBotView.tsx +0 -297
  675. package/src/AI/AIAssistBot/configuration.ts +0 -23
  676. package/src/AI/AIAssistBot/resources/CloseIcon.png +0 -0
  677. package/src/AI/AIAssistBot/resources/index.ts +0 -6
  678. package/src/AI/AIBaseConfiguration.ts +0 -15
  679. package/src/AI/AIBaseStyle.ts +0 -58
  680. package/src/AI/AIConversationStarter/AIConversationStarter.ts +0 -19
  681. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +0 -249
  682. package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +0 -14
  683. package/src/AI/AIConversationStarter/configuration.ts +0 -11
  684. package/src/AI/AIConversationStarter/style.ts +0 -74
  685. package/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx +0 -179
  686. package/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts +0 -21
  687. package/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx +0 -20
  688. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +0 -195
  689. package/src/AI/AIConversationSummary/configuration.ts +0 -14
  690. package/src/AI/AIConversationSummary/resources/index.ts +0 -6
  691. package/src/AI/AIExtensionDataSource.ts +0 -18
  692. package/src/AI/AIOptionsStyle.ts +0 -14
  693. package/src/AI/AISmartReplies/AISmartReplies.ts +0 -19
  694. package/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx +0 -306
  695. package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +0 -16
  696. package/src/AI/AISmartReplies/configuration.ts +0 -12
  697. package/src/AI/CardView.tsx +0 -83
  698. package/src/AI/CardViewStyle.ts +0 -37
  699. package/src/AI/resources/ai-empty.png +0 -0
  700. package/src/AI/resources/ai-error.png +0 -0
  701. package/src/AI/resources/index.ts +0 -12
  702. package/src/AI/resources/spineer.png +0 -0
  703. package/src/AI/style.ts +0 -165
  704. package/src/AI/utils.ts +0 -39
  705. package/src/CometChatAddMembers/AddMembersConfiguration.tsx +0 -58
  706. package/src/CometChatAddMembers/CometChatAddMembers.tsx +0 -114
  707. package/src/CometChatAddMembers/index.ts +0 -10
  708. package/src/CometChatBannedMembers/BannedMembersConfiguration.tsx +0 -61
  709. package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +0 -148
  710. package/src/CometChatBannedMembers/index.ts +0 -13
  711. package/src/CometChatBannedMembers/resources/clear.png +0 -0
  712. package/src/CometChatBannedMembers/resources/index.ts +0 -4
  713. package/src/CometChatContacts/CometChatContacts.tsx +0 -229
  714. package/src/CometChatContacts/ContactsConfiguration.tsx +0 -69
  715. package/src/CometChatContacts/ContactsStyle.ts +0 -60
  716. package/src/CometChatContacts/Header.tsx +0 -167
  717. package/src/CometChatContacts/index.ts +0 -13
  718. package/src/CometChatContacts/styles.ts +0 -105
  719. package/src/CometChatConversations/ConversationsConfiguration.ts +0 -226
  720. package/src/CometChatConversations/ConversationsStyle.ts +0 -88
  721. package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +0 -232
  722. package/src/CometChatConversationsWithMessages/index.ts +0 -6
  723. package/src/CometChatConversationsWithMessages/resources/index.ts +0 -6
  724. package/src/CometChatConversationsWithMessages/resources/start.png +0 -0
  725. package/src/CometChatConversationsWithMessages/styles.ts +0 -15
  726. package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +0 -382
  727. package/src/CometChatCreateGroup/CreateGroupConfiguration.ts +0 -36
  728. package/src/CometChatCreateGroup/Header.tsx +0 -60
  729. package/src/CometChatCreateGroup/index.ts +0 -15
  730. package/src/CometChatCreateGroup/resources/close.png +0 -0
  731. package/src/CometChatCreateGroup/resources/index.ts +0 -11
  732. package/src/CometChatCreateGroup/resources/rightTick.png +0 -0
  733. package/src/CometChatCreateGroup/resources/warning.png +0 -0
  734. package/src/CometChatCreateGroup/style.ts +0 -44
  735. package/src/CometChatDetails/CometChatDetails.tsx +0 -983
  736. package/src/CometChatDetails/DetailsConfiguration.tsx +0 -72
  737. package/src/CometChatDetails/Header.tsx +0 -42
  738. package/src/CometChatDetails/index.ts +0 -19
  739. package/src/CometChatDetails/listners.ts +0 -109
  740. package/src/CometChatDetails/resources/close.png +0 -0
  741. package/src/CometChatDetails/resources/index.ts +0 -17
  742. package/src/CometChatDetails/styles.ts +0 -23
  743. package/src/CometChatGroupMembers/GroupMemberConfiguration.ts +0 -118
  744. package/src/CometChatGroupMembers/GroupMemberStyle.ts +0 -91
  745. package/src/CometChatGroupMembers/GroupScopeStyle.ts +0 -68
  746. package/src/CometChatGroups/GroupsConfiguration.ts +0 -93
  747. package/src/CometChatGroupsWithMessages/CometChatGroupsWithMessages.tsx +0 -234
  748. package/src/CometChatGroupsWithMessages/index.ts +0 -6
  749. package/src/CometChatGroupsWithMessages/resources/index.ts +0 -5
  750. package/src/CometChatGroupsWithMessages/resources/write.png +0 -0
  751. package/src/CometChatGroupsWithMessages/styles.ts +0 -15
  752. package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +0 -268
  753. package/src/CometChatJoinProtectedGroup/Header.tsx +0 -52
  754. package/src/CometChatJoinProtectedGroup/JoinProtectedGroupConfiguration.ts +0 -30
  755. package/src/CometChatJoinProtectedGroup/index.ts +0 -15
  756. package/src/CometChatJoinProtectedGroup/resources/close.png +0 -0
  757. package/src/CometChatJoinProtectedGroup/resources/index.ts +0 -8
  758. package/src/CometChatJoinProtectedGroup/resources/rightTick.png +0 -0
  759. package/src/CometChatJoinProtectedGroup/style.ts +0 -11
  760. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +0 -96
  761. package/src/CometChatMessageComposer/styles.ts +0 -28
  762. package/src/CometChatMessageHeader/MessageHeaderConfiguration.tsx +0 -62
  763. package/src/CometChatMessageHeader/resources/Back.png +0 -0
  764. package/src/CometChatMessageHeader/resources/index.ts +0 -11
  765. package/src/CometChatMessageHeader/resources/password.png +0 -0
  766. package/src/CometChatMessageHeader/resources/private.png +0 -0
  767. package/src/CometChatMessageInformation/MessageInformationConfiguration.tsx +0 -32
  768. package/src/CometChatMessageInformation/MessageInformationStyle.ts +0 -12
  769. package/src/CometChatMessageList/MessageListConfiguration.ts +0 -250
  770. package/src/CometChatMessageList/MessageListStyle.ts +0 -75
  771. package/src/CometChatMessages/CometChatMessages.tsx +0 -347
  772. package/src/CometChatMessages/MessageStyle.ts +0 -34
  773. package/src/CometChatMessages/MessagesConfiguration.ts +0 -55
  774. package/src/CometChatMessages/index.ts +0 -16
  775. package/src/CometChatMessages/resources/index.ts +0 -6
  776. package/src/CometChatMessages/resources/info.png +0 -0
  777. package/src/CometChatMessages/style.ts +0 -23
  778. package/src/CometChatTabs/CometChatTabs.tsx +0 -178
  779. package/src/CometChatTabs/CometChatTabsStyle.ts +0 -45
  780. package/src/CometChatTabs/TabItemStyle.ts +0 -55
  781. package/src/CometChatTabs/TabItems.ts +0 -11
  782. package/src/CometChatTabs/index.ts +0 -6
  783. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +0 -345
  784. package/src/CometChatThreadedMessages/Header.tsx +0 -57
  785. package/src/CometChatThreadedMessages/ThreadedMessagesConfiguration.ts +0 -45
  786. package/src/CometChatThreadedMessages/index.ts +0 -15
  787. package/src/CometChatThreadedMessages/resources/Back.png +0 -0
  788. package/src/CometChatThreadedMessages/resources/close.png +0 -0
  789. package/src/CometChatThreadedMessages/resources/index.ts +0 -20
  790. package/src/CometChatThreadedMessages/resources/password.png +0 -0
  791. package/src/CometChatThreadedMessages/resources/private.png +0 -0
  792. package/src/CometChatThreadedMessages/resources/right-arrow.png +0 -0
  793. package/src/CometChatThreadedMessages/style.ts +0 -29
  794. package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +0 -145
  795. package/src/CometChatTransferOwnership/TransferOwnershipConfiguration.ts +0 -60
  796. package/src/CometChatTransferOwnership/index.ts +0 -14
  797. package/src/CometChatUsers/UsersConfiguration.tsx +0 -59
  798. package/src/CometChatUsers/UsersStyle.ts +0 -101
  799. package/src/CometChatUsersWithMessages/CometChatUsersWithMessages.tsx +0 -130
  800. package/src/CometChatUsersWithMessages/index.ts +0 -6
  801. package/src/CometChatUsersWithMessages/styles.ts +0 -15
  802. package/src/calls/CallingDetailsUtils.tsx +0 -158
  803. package/src/calls/CallingExtentionDecorator.tsx +0 -222
  804. package/src/calls/CometChatCallBubble/CallBubbleConfiguration.ts +0 -23
  805. package/src/calls/CometChatCallBubble/CallBubbleStyle.ts +0 -47
  806. package/src/calls/CometChatCallButtons/CallButtonStyle.ts +0 -35
  807. package/src/calls/CometChatCallButtons/resources/Call.png +0 -0
  808. package/src/calls/CometChatCallButtons/resources/Video.png +0 -0
  809. package/src/calls/CometChatCallButtons/resources/index.ts +0 -9
  810. package/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts +0 -118
  811. package/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts +0 -36
  812. package/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx +0 -309
  813. package/src/calls/CometChatCallLogDetails/index.ts +0 -23
  814. package/src/calls/CometChatCallLogDetails/resources/CloseIcon.png +0 -0
  815. package/src/calls/CometChatCallLogDetails/resources/index.ts +0 -5
  816. package/src/calls/CometChatCallLogDetails/style.ts +0 -15
  817. package/src/calls/CometChatCallLogHistory/CallLogHistoryConfiguration.ts +0 -67
  818. package/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts +0 -46
  819. package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +0 -350
  820. package/src/calls/CometChatCallLogHistory/index.ts +0 -23
  821. package/src/calls/CometChatCallLogHistory/resources/Back.png +0 -0
  822. package/src/calls/CometChatCallLogHistory/resources/Call.png +0 -0
  823. package/src/calls/CometChatCallLogHistory/resources/Info.png +0 -0
  824. package/src/calls/CometChatCallLogHistory/resources/Selection.png +0 -0
  825. package/src/calls/CometChatCallLogHistory/resources/Spineer.png +0 -0
  826. package/src/calls/CometChatCallLogHistory/resources/Video.png +0 -0
  827. package/src/calls/CometChatCallLogHistory/resources/check.png +0 -0
  828. package/src/calls/CometChatCallLogHistory/resources/incomingcall.png +0 -0
  829. package/src/calls/CometChatCallLogHistory/resources/incomingvideo.png +0 -0
  830. package/src/calls/CometChatCallLogHistory/resources/index.ts +0 -42
  831. package/src/calls/CometChatCallLogHistory/resources/missedcall.png +0 -0
  832. package/src/calls/CometChatCallLogHistory/resources/missedvideo.png +0 -0
  833. package/src/calls/CometChatCallLogHistory/resources/outgoingcall.png +0 -0
  834. package/src/calls/CometChatCallLogHistory/resources/outgoingvideo.png +0 -0
  835. package/src/calls/CometChatCallLogHistory/style.ts +0 -24
  836. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts +0 -63
  837. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts +0 -59
  838. package/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx +0 -221
  839. package/src/calls/CometChatCallLogParticipants/index.ts +0 -23
  840. package/src/calls/CometChatCallLogParticipants/resources/Back.png +0 -0
  841. package/src/calls/CometChatCallLogParticipants/resources/index.ts +0 -5
  842. package/src/calls/CometChatCallLogParticipants/style.ts +0 -24
  843. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts +0 -65
  844. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts +0 -63
  845. package/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx +0 -254
  846. package/src/calls/CometChatCallLogRecordings/index.ts +0 -23
  847. package/src/calls/CometChatCallLogRecordings/resources/Back.png +0 -0
  848. package/src/calls/CometChatCallLogRecordings/resources/download.png +0 -0
  849. package/src/calls/CometChatCallLogRecordings/resources/index.ts +0 -8
  850. package/src/calls/CometChatCallLogRecordings/style.ts +0 -24
  851. package/src/calls/CometChatCallLogs/CallLogsConfiguration.ts +0 -89
  852. package/src/calls/CometChatCallLogs/CallLogsStyle.ts +0 -95
  853. package/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts +0 -10
  854. package/src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx +0 -56
  855. package/src/calls/CometChatCallLogsWithDetails/index.ts +0 -5
  856. package/src/calls/CometChatCallLogsWithDetails/style.ts +0 -11
  857. package/src/calls/CometChatIncomingCall/IncomingCallStyle.ts +0 -75
  858. package/src/calls/CometChatIncomingCall/styles.ts +0 -10
  859. package/src/calls/CometChatOngoingCall/OngoingCallStyle.ts +0 -25
  860. package/src/calls/CometChatOutgoingCall/OutgoingCallStyle.ts +0 -39
  861. package/src/extensions/CollaborativeBubble/CollaborativeBubbleStyle.ts +0 -97
  862. package/src/extensions/CollaborativeBubble/styles.ts +0 -82
  863. package/src/extensions/CollaborativeDocument/CollaborativeDocumentConfiguration.tsx +0 -26
  864. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardConfiguration.tsx +0 -26
  865. package/src/extensions/ImageModeration/ImageModerationDecorator.tsx +0 -82
  866. package/src/extensions/ImageModeration/ImageModerationExtension.tsx +0 -43
  867. package/src/extensions/ImageModeration/ImageModerationFilter.tsx +0 -145
  868. package/src/extensions/ImageModeration/index.ts +0 -18
  869. package/src/extensions/ImageModeration/resources/index.ts +0 -4
  870. package/src/extensions/ImageModeration/resources/unsafe.png +0 -0
  871. package/src/extensions/LinkPreview/LInkPreviewBubbleStyle.ts +0 -28
  872. package/src/extensions/LinkPreview/LinkPreviewConfiguration.ts +0 -27
  873. package/src/extensions/LinkPreview/LinkPreviewExtention.tsx +0 -25
  874. package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +0 -55
  875. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +0 -144
  876. package/src/extensions/SmartReplies/SmartRepliesExtension.tsx +0 -52
  877. package/src/extensions/SmartReplies/SmartRepliesView.tsx +0 -213
  878. package/src/extensions/SmartReplies/index.ts +0 -7
  879. package/src/extensions/SmartReplies/resources/close.png +0 -0
  880. package/src/extensions/SmartReplies/resources/index.ts +0 -6
  881. package/src/extensions/Stickers/CometChatStickerKeyboard/StickerKeyboardStyle.ts +0 -52
  882. package/src/extensions/Stickers/StickerStyle.ts +0 -15
  883. package/src/extensions/TextModeration/TextModerationConfiguration.tsx +0 -25
  884. package/src/extensions/TextModeration/TextModerationExtension.tsx +0 -51
  885. package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +0 -93
  886. package/src/extensions/TextModeration/index.ts +0 -6
  887. package/src/shared/CometChatContext.tsx +0 -43
  888. package/src/shared/helper/SwipeRow.js +0 -944
  889. package/src/shared/libs/CometChatCalendar/Calendars/BaseCalendar.tsx +0 -229
  890. package/src/shared/libs/CometChatCalendar/Calendars/DateSelectionCalendar.tsx +0 -90
  891. package/src/shared/libs/CometChatCalendar/Calendars/MultiDateSelectionCalendar.tsx +0 -108
  892. package/src/shared/libs/CometChatCalendar/Calendars/Providers.tsx +0 -27
  893. package/src/shared/libs/CometChatCalendar/Calendars/index.ts +0 -3
  894. package/src/shared/libs/CometChatCalendar/Components/Arrow.tsx +0 -46
  895. package/src/shared/libs/CometChatCalendar/Components/Day.tsx +0 -95
  896. package/src/shared/libs/CometChatCalendar/Components/Days.tsx +0 -110
  897. package/src/shared/libs/CometChatCalendar/Components/Month.tsx +0 -47
  898. package/src/shared/libs/CometChatCalendar/Components/Months.tsx +0 -79
  899. package/src/shared/libs/CometChatCalendar/Components/Title.tsx +0 -47
  900. package/src/shared/libs/CometChatCalendar/Components/Weekdays.tsx +0 -29
  901. package/src/shared/libs/CometChatCalendar/Components/index.ts +0 -7
  902. package/src/shared/libs/CometChatCalendar/Constants/View.ts +0 -4
  903. package/src/shared/libs/CometChatCalendar/Constants/index.ts +0 -1
  904. package/src/shared/libs/CometChatCalendar/Contexts/LocaleContext.tsx +0 -7
  905. package/src/shared/libs/CometChatCalendar/Contexts/ThemeContext.tsx +0 -7
  906. package/src/shared/libs/CometChatCalendar/Contexts/index.ts +0 -2
  907. package/src/shared/libs/CometChatCalendar/Entities/ArrowDirections.ts +0 -1
  908. package/src/shared/libs/CometChatCalendar/Entities/Calendar.ts +0 -26
  909. package/src/shared/libs/CometChatCalendar/Entities/Components.ts +0 -13
  910. package/src/shared/libs/CometChatCalendar/Entities/DateProperties.ts +0 -6
  911. package/src/shared/libs/CometChatCalendar/Entities/Locale.ts +0 -12
  912. package/src/shared/libs/CometChatCalendar/Entities/Theme.ts +0 -70
  913. package/src/shared/libs/CometChatCalendar/Entities/index.ts +0 -6
  914. package/src/shared/libs/CometChatCalendar/Hooks/index.ts +0 -1
  915. package/src/shared/libs/CometChatCalendar/Hooks/useSurroundingTimeUnits.ts +0 -63
  916. package/src/shared/libs/CometChatCalendar/Icons/BackArrow.png +0 -0
  917. package/src/shared/libs/CometChatCalendar/Icons/chevron-left-16.png +0 -0
  918. package/src/shared/libs/CometChatCalendar/Icons/index.ts +0 -7
  919. package/src/shared/libs/CometChatCalendar/Locales/index.ts +0 -4
  920. package/src/shared/libs/CometChatCalendar/Themes/Colors.ts +0 -31
  921. package/src/shared/libs/CometChatCalendar/Themes/DarkTheme.ts +0 -79
  922. package/src/shared/libs/CometChatCalendar/Themes/DefaultTheme.ts +0 -164
  923. package/src/shared/libs/CometChatCalendar/Themes/index.ts +0 -3
  924. package/src/shared/libs/CometChatCalendar/Utils/addOpacity.ts +0 -15
  925. package/src/shared/libs/CometChatCalendar/Utils/checkChangedProps.ts +0 -10
  926. package/src/shared/libs/CometChatCalendar/Utils/clamp.ts +0 -5
  927. package/src/shared/libs/CometChatCalendar/Utils/dateRange.ts +0 -23
  928. package/src/shared/libs/CometChatCalendar/Utils/getExtraDays.ts +0 -25
  929. package/src/shared/libs/CometChatCalendar/Utils/getSurroundingTimeUnits.ts +0 -20
  930. package/src/shared/libs/CometChatCalendar/Utils/index.ts +0 -6
  931. package/src/shared/libs/CometChatCalendar/index.ts +0 -5
  932. package/src/shared/libs/VideoPlayer/Video.js +0 -494
  933. package/src/shared/libs/VideoPlayerControls/OSSupport/PlatformSupport.tsx +0 -43
  934. package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +0 -17
  935. package/src/shared/libs/VideoPlayerControls/OSSupport/index.tsx +0 -1
  936. package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +0 -512
  937. package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
  938. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette.png +0 -0
  939. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@2x.png +0 -0
  940. package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@3x.png +0 -0
  941. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon.png +0 -0
  942. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@2x.png +0 -0
  943. package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@3x.png +0 -0
  944. package/src/shared/libs/VideoPlayerControls/assets/img/expand.png +0 -0
  945. package/src/shared/libs/VideoPlayerControls/assets/img/expand@2x.png +0 -0
  946. package/src/shared/libs/VideoPlayerControls/assets/img/expand@3x.png +0 -0
  947. package/src/shared/libs/VideoPlayerControls/assets/img/forward.png +0 -0
  948. package/src/shared/libs/VideoPlayerControls/assets/img/forward@2x.png +0 -0
  949. package/src/shared/libs/VideoPlayerControls/assets/img/forward@3x.png +0 -0
  950. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon.png +0 -0
  951. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@2x.png +0 -0
  952. package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@3x.png +0 -0
  953. package/src/shared/libs/VideoPlayerControls/assets/img/pause.png +0 -0
  954. package/src/shared/libs/VideoPlayerControls/assets/img/pause@2x.png +0 -0
  955. package/src/shared/libs/VideoPlayerControls/assets/img/pause@3x.png +0 -0
  956. package/src/shared/libs/VideoPlayerControls/assets/img/play.png +0 -0
  957. package/src/shared/libs/VideoPlayerControls/assets/img/play@2x.png +0 -0
  958. package/src/shared/libs/VideoPlayerControls/assets/img/play@3x.png +0 -0
  959. package/src/shared/libs/VideoPlayerControls/assets/img/rewind.png +0 -0
  960. package/src/shared/libs/VideoPlayerControls/assets/img/rewind@2x.png +0 -0
  961. package/src/shared/libs/VideoPlayerControls/assets/img/rewind@3x.png +0 -0
  962. package/src/shared/libs/VideoPlayerControls/assets/img/shrink.png +0 -0
  963. package/src/shared/libs/VideoPlayerControls/assets/img/shrink@2x.png +0 -0
  964. package/src/shared/libs/VideoPlayerControls/assets/img/shrink@3x.png +0 -0
  965. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette.png +0 -0
  966. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@2x.png +0 -0
  967. package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@3x.png +0 -0
  968. package/src/shared/libs/VideoPlayerControls/assets/img/volume.png +0 -0
  969. package/src/shared/libs/VideoPlayerControls/assets/img/volume@2x.png +0 -0
  970. package/src/shared/libs/VideoPlayerControls/assets/img/volume@3x.png +0 -0
  971. package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +0 -28
  972. package/src/shared/libs/VideoPlayerControls/components/Back/index.ts +0 -1
  973. package/src/shared/libs/VideoPlayerControls/components/BottomControls.tsx +0 -142
  974. package/src/shared/libs/VideoPlayerControls/components/Control.tsx +0 -45
  975. package/src/shared/libs/VideoPlayerControls/components/Error/Error.tsx +0 -22
  976. package/src/shared/libs/VideoPlayerControls/components/Error/index.ts +0 -1
  977. package/src/shared/libs/VideoPlayerControls/components/Error/styles.ts +0 -21
  978. package/src/shared/libs/VideoPlayerControls/components/Fullscreen.tsx +0 -36
  979. package/src/shared/libs/VideoPlayerControls/components/Loader/Loader.tsx +0 -15
  980. package/src/shared/libs/VideoPlayerControls/components/Loader/index.ts +0 -1
  981. package/src/shared/libs/VideoPlayerControls/components/Loader/styles.ts +0 -16
  982. package/src/shared/libs/VideoPlayerControls/components/NullControl.tsx +0 -7
  983. package/src/shared/libs/VideoPlayerControls/components/Overlay.tsx +0 -23
  984. package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +0 -109
  985. package/src/shared/libs/VideoPlayerControls/components/PlayPause/index.ts +0 -1
  986. package/src/shared/libs/VideoPlayerControls/components/PlayPause/styles.ts +0 -21
  987. package/src/shared/libs/VideoPlayerControls/components/Seekbar/Seekbar.tsx +0 -47
  988. package/src/shared/libs/VideoPlayerControls/components/Seekbar/index.ts +0 -1
  989. package/src/shared/libs/VideoPlayerControls/components/Seekbar/styles.ts +0 -37
  990. package/src/shared/libs/VideoPlayerControls/components/Timer/Timer.tsx +0 -28
  991. package/src/shared/libs/VideoPlayerControls/components/Timer/index.ts +0 -1
  992. package/src/shared/libs/VideoPlayerControls/components/Timer/styles.ts +0 -12
  993. package/src/shared/libs/VideoPlayerControls/components/Title.tsx +0 -35
  994. package/src/shared/libs/VideoPlayerControls/components/TopControls.tsx +0 -110
  995. package/src/shared/libs/VideoPlayerControls/components/Volume/Volume.tsx +0 -37
  996. package/src/shared/libs/VideoPlayerControls/components/Volume/index.ts +0 -1
  997. package/src/shared/libs/VideoPlayerControls/components/Volume/styles.ts +0 -31
  998. package/src/shared/libs/VideoPlayerControls/components/index.ts +0 -14
  999. package/src/shared/libs/VideoPlayerControls/components/styles.ts +0 -30
  1000. package/src/shared/libs/VideoPlayerControls/hooks/index.ts +0 -3
  1001. package/src/shared/libs/VideoPlayerControls/hooks/useAnimations.ts +0 -68
  1002. package/src/shared/libs/VideoPlayerControls/hooks/useControlTimeout.tsx +0 -67
  1003. package/src/shared/libs/VideoPlayerControls/hooks/usePanResponders.tsx +0 -96
  1004. package/src/shared/libs/VideoPlayerControls/index.ts +0 -4
  1005. package/src/shared/libs/VideoPlayerControls/styles.ts +0 -19
  1006. package/src/shared/libs/VideoPlayerControls/types.ts +0 -290
  1007. package/src/shared/libs/VideoPlayerControls/utils.ts +0 -76
  1008. package/src/shared/libs/datePickerModal/DateTimePickerModal.android.js +0 -75
  1009. package/src/shared/libs/datePickerModal/DateTimePickerModal.ios.js +0 -363
  1010. package/src/shared/libs/datePickerModal/DateTimePickerModal.js +0 -9
  1011. package/src/shared/libs/datePickerModal/Modal.js +0 -180
  1012. package/src/shared/libs/datePickerModal/index.d.ts +0 -310
  1013. package/src/shared/libs/datePickerModal/index.js +0 -5
  1014. package/src/shared/libs/datePickerModal/utils.js +0 -25
  1015. package/src/shared/libs/luxon/src/datetime.js +0 -2422
  1016. package/src/shared/libs/luxon/src/duration.js +0 -990
  1017. package/src/shared/libs/luxon/src/errors.js +0 -61
  1018. package/src/shared/libs/luxon/src/impl/conversions.js +0 -206
  1019. package/src/shared/libs/luxon/src/impl/diff.js +0 -95
  1020. package/src/shared/libs/luxon/src/impl/digits.js +0 -75
  1021. package/src/shared/libs/luxon/src/impl/english.js +0 -233
  1022. package/src/shared/libs/luxon/src/impl/formats.js +0 -176
  1023. package/src/shared/libs/luxon/src/impl/formatter.js +0 -409
  1024. package/src/shared/libs/luxon/src/impl/invalid.js +0 -14
  1025. package/src/shared/libs/luxon/src/impl/locale.js +0 -542
  1026. package/src/shared/libs/luxon/src/impl/regexParser.js +0 -335
  1027. package/src/shared/libs/luxon/src/impl/tokenParser.js +0 -473
  1028. package/src/shared/libs/luxon/src/impl/util.js +0 -309
  1029. package/src/shared/libs/luxon/src/impl/zoneUtil.js +0 -30
  1030. package/src/shared/libs/luxon/src/info.js +0 -205
  1031. package/src/shared/libs/luxon/src/interval.js +0 -657
  1032. package/src/shared/libs/luxon/src/luxon.js +0 -26
  1033. package/src/shared/libs/luxon/src/package.json +0 -4
  1034. package/src/shared/libs/luxon/src/settings.js +0 -175
  1035. package/src/shared/libs/luxon/src/zone.js +0 -91
  1036. package/src/shared/libs/luxon/src/zones/IANAZone.js +0 -189
  1037. package/src/shared/libs/luxon/src/zones/fixedOffsetZone.js +0 -102
  1038. package/src/shared/libs/luxon/src/zones/invalidZone.js +0 -53
  1039. package/src/shared/libs/luxon/src/zones/systemZone.js +0 -61
  1040. package/src/shared/modals/CometChatCallLogDetailsOptions.ts +0 -23
  1041. package/src/shared/modals/CometChatCallLogDetailsTemplate.ts +0 -16
  1042. package/src/shared/modals/CometChatDetailsOption.ts +0 -24
  1043. package/src/shared/modals/CometChatDetailsTemplate.ts +0 -16
  1044. package/src/shared/modals/CometChatOptions.ts +0 -13
  1045. package/src/shared/modals/InteractiveData/InteractiveActions/APIAction.ts +0 -118
  1046. package/src/shared/modals/InteractiveData/InteractiveActions/CustomAction.ts +0 -19
  1047. package/src/shared/modals/InteractiveData/InteractiveActions/URLNavigationAction.ts +0 -34
  1048. package/src/shared/modals/InteractiveData/InteractiveActions/index.ts +0 -3
  1049. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveCardData.ts +0 -69
  1050. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveFormData.ts +0 -119
  1051. package/src/shared/modals/InteractiveData/InteractiveData/index.ts +0 -2
  1052. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInputElement.ts +0 -102
  1053. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInteractiveElement.ts +0 -45
  1054. package/src/shared/modals/InteractiveData/InteractiveElements/ButtonElement.ts +0 -61
  1055. package/src/shared/modals/InteractiveData/InteractiveElements/CheckboxElement.ts +0 -75
  1056. package/src/shared/modals/InteractiveData/InteractiveElements/DateTimeElement.ts +0 -103
  1057. package/src/shared/modals/InteractiveData/InteractiveElements/DropdownElement.ts +0 -83
  1058. package/src/shared/modals/InteractiveData/InteractiveElements/LabelElement.ts +0 -32
  1059. package/src/shared/modals/InteractiveData/InteractiveElements/OptionElement.ts +0 -39
  1060. package/src/shared/modals/InteractiveData/InteractiveElements/RadioButtonElement.ts +0 -76
  1061. package/src/shared/modals/InteractiveData/InteractiveElements/SingleSelectElement.ts +0 -76
  1062. package/src/shared/modals/InteractiveData/InteractiveElements/TextInputElement.ts +0 -101
  1063. package/src/shared/modals/InteractiveData/InteractiveElements/index.ts +0 -11
  1064. package/src/shared/modals/InteractiveData/InteractiveEntities/ActionEntity.ts +0 -41
  1065. package/src/shared/modals/InteractiveData/InteractiveEntities/ElementEntity.ts +0 -66
  1066. package/src/shared/modals/InteractiveData/InteractiveEntities/index.ts +0 -2
  1067. package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +0 -143
  1068. package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +0 -39
  1069. package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +0 -153
  1070. package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +0 -150
  1071. package/src/shared/modals/InteractiveData/InteractiveMessage/index.ts +0 -4
  1072. package/src/shared/modals/InteractiveData/index.ts +0 -30
  1073. package/src/shared/resources/CometChatTheme/CometChatTheme.ts +0 -28
  1074. package/src/shared/resources/CometChatTheme/Palette.ts +0 -584
  1075. package/src/shared/resources/CometChatTheme/Typography.ts +0 -396
  1076. package/src/shared/resources/CometChatTheme/index.ts +0 -2
  1077. package/src/shared/utils/CometChatLiveReactions/CometChatLiveReaction.tsx +0 -124
  1078. package/src/shared/utils/CometChatLiveReactions/LiveReactionstyles.ts +0 -37
  1079. package/src/shared/utils/CometChatLiveReactions/index.ts +0 -1
  1080. package/src/shared/utils/CometChatLiveReactions/resources/heart.png +0 -0
  1081. package/src/shared/utils/CometChatLiveReactions/resources/index.ts +0 -5
  1082. package/src/shared/utils/CometChatLiveReactions/style.ts +0 -8
  1083. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +0 -109
  1084. package/src/shared/utils/CometChatMessagePreview/MessagePreviewConfiguration.js +0 -30
  1085. package/src/shared/utils/CometChatMessagePreview/style.js +0 -71
  1086. package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +0 -399
  1087. package/src/shared/utils/DetailsUtils/resources/Back.png +0 -0
  1088. package/src/shared/utils/DetailsUtils/resources/banIcon.png +0 -0
  1089. package/src/shared/utils/DetailsUtils/resources/close.png +0 -0
  1090. package/src/shared/utils/DetailsUtils/resources/index.ts +0 -23
  1091. package/src/shared/utils/DetailsUtils/resources/kickIcon.png +0 -0
  1092. package/src/shared/utils/DetailsUtils/resources/password.png +0 -0
  1093. package/src/shared/utils/DetailsUtils/resources/private.png +0 -0
  1094. package/src/shared/utils/DetailsUtils/resources/right-arrow.png +0 -0
  1095. package/src/shared/utils/InteractiveMessageUtils.ts +0 -60
  1096. package/src/shared/utils/SchedulerUtils.ts +0 -198
  1097. package/src/shared/utils/TypeUtils.ts +0 -3
  1098. package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +0 -61
  1099. package/src/shared/views/CometChatAudioBubble/AudioBubbleStyle.ts +0 -43
  1100. package/src/shared/views/CometChatAvatar/AvatarConfiguration.ts +0 -27
  1101. package/src/shared/views/CometChatAvatar/AvatarStyle.ts +0 -57
  1102. package/src/shared/views/CometChatAvatar/resources/default.jpg +0 -0
  1103. package/src/shared/views/CometChatAvatar/resources/index.ts +0 -5
  1104. package/src/shared/views/CometChatBadge/BadgeConfiguration.ts +0 -55
  1105. package/src/shared/views/CometChatBadge/BadgeStyle.ts +0 -39
  1106. package/src/shared/views/CometChatBottomSheet/style.ts +0 -50
  1107. package/src/shared/views/CometChatButton/CometChatButton.tsx +0 -76
  1108. package/src/shared/views/CometChatButton/CometChatButtonStyle.ts +0 -47
  1109. package/src/shared/views/CometChatButton/index.ts +0 -5
  1110. package/src/shared/views/CometChatButton/style.ts +0 -8
  1111. package/src/shared/views/CometChatCard/CometChatCard.tsx +0 -77
  1112. package/src/shared/views/CometChatCard/CometChatCardStyle.ts +0 -31
  1113. package/src/shared/views/CometChatCard/index.ts +0 -8
  1114. package/src/shared/views/CometChatCard/style.ts +0 -13
  1115. package/src/shared/views/CometChatCardBubble/CardBubbleStyle.tsx +0 -47
  1116. package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +0 -174
  1117. package/src/shared/views/CometChatCardBubble/index.tsx +0 -2
  1118. package/src/shared/views/CometChatCheckBox/CheckBoxStyle.tsx +0 -43
  1119. package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +0 -79
  1120. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialogStyle.ts +0 -36
  1121. package/src/shared/views/CometChatDate/DateConfiguration.ts +0 -32
  1122. package/src/shared/views/CometChatDate/DateStyle.ts +0 -26
  1123. package/src/shared/views/CometChatDate/style.ts +0 -8
  1124. package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +0 -206
  1125. package/src/shared/views/CometChatDateTimePicker/DateTimePickerStyle.ts +0 -19
  1126. package/src/shared/views/CometChatDateTimePicker/index.ts +0 -3
  1127. package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +0 -127
  1128. package/src/shared/views/CometChatDropDown/DropDownStyle.tsx +0 -39
  1129. package/src/shared/views/CometChatDropDown/resources/downArrowIcon.png +0 -0
  1130. package/src/shared/views/CometChatDropDown/resources/index.js +0 -5
  1131. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +0 -27
  1132. package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +0 -44
  1133. package/src/shared/views/CometChatFileBubble/FileBubbleStyle.ts +0 -58
  1134. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +0 -542
  1135. package/src/shared/views/CometChatFormBubble/FormBubbleStyle.tsx +0 -96
  1136. package/src/shared/views/CometChatFormBubble/index.tsx +0 -2
  1137. package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +0 -34
  1138. package/src/shared/views/CometChatImageBubble/assets/default_image.png +0 -0
  1139. package/src/shared/views/CometChatLabel/CometChatLabel.tsx +0 -27
  1140. package/src/shared/views/CometChatLabel/LabelStyle.ts +0 -19
  1141. package/src/shared/views/CometChatList/resources/Back.png +0 -0
  1142. package/src/shared/views/CometChatList/resources/Search.png +0 -0
  1143. package/src/shared/views/CometChatListItem/ListItemConfiguration.tsx +0 -21
  1144. package/src/shared/views/CometChatListItem/ListItemStyle.ts +0 -47
  1145. package/src/shared/views/CometChatMediaRecorder/MediaRecorderStyle.ts +0 -63
  1146. package/src/shared/views/CometChatMessageBubble/MessageBubbleStyle.ts +0 -26
  1147. package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +0 -13
  1148. package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +0 -66
  1149. package/src/shared/views/CometChatQuickView/QuickViewStyle.ts +0 -55
  1150. package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +0 -67
  1151. package/src/shared/views/CometChatRadioButton/RadioButtonStyle.tsx +0 -38
  1152. package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +0 -15
  1153. package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +0 -13
  1154. package/src/shared/views/CometChatReactions/ReactionsStyle.tsx +0 -43
  1155. package/src/shared/views/CometChatReceipt/MessageConfiguration.ts +0 -65
  1156. package/src/shared/views/CometChatReceipt/ReceiptStyle.ts +0 -3
  1157. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +0 -1519
  1158. package/src/shared/views/CometChatSchedulerBubble/index.ts +0 -3
  1159. package/src/shared/views/CometChatSchedulerBubble/styles.ts +0 -92
  1160. package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +0 -63
  1161. package/src/shared/views/CometChatSingleSelect/SingleStyle.tsx +0 -35
  1162. package/src/shared/views/CometChatStatusIndicator/StatusIndicatorConfiguration.ts +0 -25
  1163. package/src/shared/views/CometChatStatusIndicator/StatusIndicatorStyle.ts +0 -37
  1164. package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +0 -23
  1165. package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -37
  1166. package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +0 -67
  1167. package/src/shared/views/CometChatTextInput/TextInputStyle.tsx +0 -26
  1168. package/src/shared/views/CometChatTimeSlotSelector/CometChatTimeSlotSelector.tsx +0 -113
  1169. package/src/shared/views/CometChatTimeSlotSelector/index.ts +0 -3
  1170. package/src/shared/views/CometChatTimeSlotSelector/styles.ts +0 -30
  1171. package/src/shared/views/CometChatVideoBubble/VideoBubbleStyle.ts +0 -87
  1172. package/src/shared/views/SwipeRow/SwipeRow.tsx +0 -126
  1173. package/src/shared/views/SwipeRow/index.ts +0 -3
  1174. package/src/shared/views/SwipeRow/style.ts +0 -30
  1175. /package/src/{shared/assets/images → CometChatGroups/resources}/search.png +0 -0
  1176. /package/src/{CometChatDetails → CometChatThreadHeader}/resources/Back.png +0 -0
  1177. /package/src/{AI/AIConversationSummary → CometChatThreadHeader}/resources/close.png +0 -0
  1178. /package/src/{CometChatThreadedMessages → CometChatThreadHeader}/resources/more.png +0 -0
  1179. /package/src/{CometChatDetails → CometChatThreadHeader}/resources/password.png +0 -0
  1180. /package/src/{CometChatDetails → CometChatThreadHeader}/resources/private.png +0 -0
  1181. /package/src/{CometChatDetails → CometChatThreadHeader}/resources/right-arrow.png +0 -0
@@ -1,2422 +0,0 @@
1
- import Duration from "./duration.js";
2
- import Interval from "./interval.js";
3
- import Settings from "./settings.js";
4
- import Info from "./info.js";
5
- import Formatter from "./impl/formatter.js";
6
- import FixedOffsetZone from "./zones/fixedOffsetZone.js";
7
- import Locale from "./impl/locale.js";
8
- import {
9
- isUndefined,
10
- maybeArray,
11
- isDate,
12
- isNumber,
13
- bestBy,
14
- daysInMonth,
15
- daysInYear,
16
- isLeapYear,
17
- weeksInWeekYear,
18
- normalizeObject,
19
- roundTo,
20
- objToLocalTS,
21
- padStart,
22
- } from "./impl/util.js";
23
- import { normalizeZone } from "./impl/zoneUtil.js";
24
- import diff from "./impl/diff.js";
25
- import { parseRFC2822Date, parseISODate, parseHTTPDate, parseSQL } from "./impl/regexParser.js";
26
- import {
27
- parseFromTokens,
28
- explainFromTokens,
29
- formatOptsToTokens,
30
- expandMacroTokens,
31
- } from "./impl/tokenParser.js";
32
- import {
33
- gregorianToWeek,
34
- weekToGregorian,
35
- gregorianToOrdinal,
36
- ordinalToGregorian,
37
- hasInvalidGregorianData,
38
- hasInvalidWeekData,
39
- hasInvalidOrdinalData,
40
- hasInvalidTimeData,
41
- usesLocalWeekValues,
42
- isoWeekdayToLocal,
43
- } from "./impl/conversions.js";
44
- import * as Formats from "./impl/formats.js";
45
- import {
46
- InvalidArgumentError,
47
- ConflictingSpecificationError,
48
- InvalidUnitError,
49
- InvalidDateTimeError,
50
- } from "./errors.js";
51
- import Invalid from "./impl/invalid.js";
52
-
53
- const INVALID = "Invalid DateTime";
54
- const MAX_DATE = 8.64e15;
55
-
56
- function unsupportedZone(zone) {
57
- return new Invalid("unsupported zone", `the zone "${zone.name}" is not supported`);
58
- }
59
-
60
- // we cache week data on the DT object and this intermediates the cache
61
- /**
62
- * @param {DateTime} dt
63
- */
64
- function possiblyCachedWeekData(dt) {
65
- if (dt.weekData === null) {
66
- dt.weekData = gregorianToWeek(dt.c);
67
- }
68
- return dt.weekData;
69
- }
70
-
71
- /**
72
- * @param {DateTime} dt
73
- */
74
- function possiblyCachedLocalWeekData(dt) {
75
- if (dt.localWeekData === null) {
76
- dt.localWeekData = gregorianToWeek(
77
- dt.c,
78
- dt.loc.getMinDaysInFirstWeek(),
79
- dt.loc.getStartOfWeek()
80
- );
81
- }
82
- return dt.localWeekData;
83
- }
84
-
85
- // clone really means, "make a new object with these modifications". all "setters" really use this
86
- // to create a new object while only changing some of the properties
87
- function clone(inst, alts) {
88
- const current = {
89
- ts: inst.ts,
90
- zone: inst.zone,
91
- c: inst.c,
92
- o: inst.o,
93
- loc: inst.loc,
94
- invalid: inst.invalid,
95
- };
96
- return new DateTime({ ...current, ...alts, old: current });
97
- }
98
-
99
- // find the right offset a given local time. The o input is our guess, which determines which
100
- // offset we'll pick in ambiguous cases (e.g. there are two 3 AMs b/c Fallback DST)
101
- function fixOffset(localTS, o, tz) {
102
- // Our UTC time is just a guess because our offset is just a guess
103
- let utcGuess = localTS - o * 60 * 1000;
104
-
105
- // Test whether the zone matches the offset for this ts
106
- const o2 = tz.offset(utcGuess);
107
-
108
- // If so, offset didn't change and we're done
109
- if (o === o2) {
110
- return [utcGuess, o];
111
- }
112
-
113
- // If not, change the ts by the difference in the offset
114
- utcGuess -= (o2 - o) * 60 * 1000;
115
-
116
- // If that gives us the local time we want, we're done
117
- const o3 = tz.offset(utcGuess);
118
- if (o2 === o3) {
119
- return [utcGuess, o2];
120
- }
121
-
122
- // If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time
123
- return [localTS - Math.min(o2, o3) * 60 * 1000, Math.max(o2, o3)];
124
- }
125
-
126
- // convert an epoch timestamp into a calendar object with the given offset
127
- function tsToObj(ts, offset) {
128
- ts += offset * 60 * 1000;
129
-
130
- const d = new Date(ts);
131
-
132
- return {
133
- year: d.getUTCFullYear(),
134
- month: d.getUTCMonth() + 1,
135
- day: d.getUTCDate(),
136
- hour: d.getUTCHours(),
137
- minute: d.getUTCMinutes(),
138
- second: d.getUTCSeconds(),
139
- millisecond: d.getUTCMilliseconds(),
140
- };
141
- }
142
-
143
- // convert a calendar object to a epoch timestamp
144
- function objToTS(obj, offset, zone) {
145
- return fixOffset(objToLocalTS(obj), offset, zone);
146
- }
147
-
148
- // create a new DT instance by adding a duration, adjusting for DSTs
149
- function adjustTime(inst, dur) {
150
- const oPre = inst.o,
151
- year = inst.c.year + Math.trunc(dur.years),
152
- month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3,
153
- c = {
154
- ...inst.c,
155
- year,
156
- month,
157
- day:
158
- Math.min(inst.c.day, daysInMonth(year, month)) +
159
- Math.trunc(dur.days) +
160
- Math.trunc(dur.weeks) * 7,
161
- },
162
- millisToAdd = Duration.fromObject({
163
- years: dur.years - Math.trunc(dur.years),
164
- quarters: dur.quarters - Math.trunc(dur.quarters),
165
- months: dur.months - Math.trunc(dur.months),
166
- weeks: dur.weeks - Math.trunc(dur.weeks),
167
- days: dur.days - Math.trunc(dur.days),
168
- hours: dur.hours,
169
- minutes: dur.minutes,
170
- seconds: dur.seconds,
171
- milliseconds: dur.milliseconds,
172
- }).as("milliseconds"),
173
- localTS = objToLocalTS(c);
174
-
175
- let [ts, o] = fixOffset(localTS, oPre, inst.zone);
176
-
177
- if (millisToAdd !== 0) {
178
- ts += millisToAdd;
179
- // that could have changed the offset by going over a DST, but we want to keep the ts the same
180
- o = inst.zone.offset(ts);
181
- }
182
-
183
- return { ts, o };
184
- }
185
-
186
- // helper useful in turning the results of parsing into real dates
187
- // by handling the zone options
188
- function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOffset) {
189
- const { setZone, zone } = opts;
190
- if ((parsed && Object.keys(parsed).length !== 0) || parsedZone) {
191
- const interpretationZone = parsedZone || zone,
192
- inst = DateTime.fromObject(parsed, {
193
- ...opts,
194
- zone: interpretationZone,
195
- specificOffset,
196
- });
197
- return setZone ? inst : inst.setZone(zone);
198
- } else {
199
- return DateTime.invalid(
200
- new Invalid("unparsable", `the input "${text}" can't be parsed as ${format}`)
201
- );
202
- }
203
- }
204
-
205
- // if you want to output a technical format (e.g. RFC 2822), this helper
206
- // helps handle the details
207
- function toTechFormat(dt, format, allowZ = true) {
208
- return dt.isValid
209
- ? Formatter.create(Locale.create("en-US"), {
210
- allowZ,
211
- forceSimple: true,
212
- }).formatDateTimeFromString(dt, format)
213
- : null;
214
- }
215
-
216
- function toISODate(o, extended) {
217
- const longFormat = o.c.year > 9999 || o.c.year < 0;
218
- let c = "";
219
- if (longFormat && o.c.year >= 0) c += "+";
220
- c += padStart(o.c.year, longFormat ? 6 : 4);
221
-
222
- if (extended) {
223
- c += "-";
224
- c += padStart(o.c.month);
225
- c += "-";
226
- c += padStart(o.c.day);
227
- } else {
228
- c += padStart(o.c.month);
229
- c += padStart(o.c.day);
230
- }
231
- return c;
232
- }
233
-
234
- function toISOTime(
235
- o,
236
- extended,
237
- suppressSeconds,
238
- suppressMilliseconds,
239
- includeOffset,
240
- extendedZone
241
- ) {
242
- let c = padStart(o.c.hour);
243
- if (extended) {
244
- c += ":";
245
- c += padStart(o.c.minute);
246
- if (o.c.millisecond !== 0 || o.c.second !== 0 || !suppressSeconds) {
247
- c += ":";
248
- }
249
- } else {
250
- c += padStart(o.c.minute);
251
- }
252
-
253
- if (o.c.millisecond !== 0 || o.c.second !== 0 || !suppressSeconds) {
254
- c += padStart(o.c.second);
255
-
256
- if (o.c.millisecond !== 0 || !suppressMilliseconds) {
257
- c += ".";
258
- c += padStart(o.c.millisecond, 3);
259
- }
260
- }
261
-
262
- if (includeOffset) {
263
- if (o.isOffsetFixed && o.offset === 0 && !extendedZone) {
264
- c += "Z";
265
- } else if (o.o < 0) {
266
- c += "-";
267
- c += padStart(Math.trunc(-o.o / 60));
268
- c += ":";
269
- c += padStart(Math.trunc(-o.o % 60));
270
- } else {
271
- c += "+";
272
- c += padStart(Math.trunc(o.o / 60));
273
- c += ":";
274
- c += padStart(Math.trunc(o.o % 60));
275
- }
276
- }
277
-
278
- if (extendedZone) {
279
- c += "[" + o.zone.ianaName + "]";
280
- }
281
- return c;
282
- }
283
-
284
- // defaults for unspecified units in the supported calendars
285
- const defaultUnitValues = {
286
- month: 1,
287
- day: 1,
288
- hour: 0,
289
- minute: 0,
290
- second: 0,
291
- millisecond: 0,
292
- },
293
- defaultWeekUnitValues = {
294
- weekNumber: 1,
295
- weekday: 1,
296
- hour: 0,
297
- minute: 0,
298
- second: 0,
299
- millisecond: 0,
300
- },
301
- defaultOrdinalUnitValues = {
302
- ordinal: 1,
303
- hour: 0,
304
- minute: 0,
305
- second: 0,
306
- millisecond: 0,
307
- };
308
-
309
- // Units in the supported calendars, sorted by bigness
310
- const orderedUnits = ["year", "month", "day", "hour", "minute", "second", "millisecond"],
311
- orderedWeekUnits = [
312
- "weekYear",
313
- "weekNumber",
314
- "weekday",
315
- "hour",
316
- "minute",
317
- "second",
318
- "millisecond",
319
- ],
320
- orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
321
-
322
- // standardize case and plurality in units
323
- function normalizeUnit(unit) {
324
- const normalized = {
325
- year: "year",
326
- years: "year",
327
- month: "month",
328
- months: "month",
329
- day: "day",
330
- days: "day",
331
- hour: "hour",
332
- hours: "hour",
333
- minute: "minute",
334
- minutes: "minute",
335
- quarter: "quarter",
336
- quarters: "quarter",
337
- second: "second",
338
- seconds: "second",
339
- millisecond: "millisecond",
340
- milliseconds: "millisecond",
341
- weekday: "weekday",
342
- weekdays: "weekday",
343
- weeknumber: "weekNumber",
344
- weeksnumber: "weekNumber",
345
- weeknumbers: "weekNumber",
346
- weekyear: "weekYear",
347
- weekyears: "weekYear",
348
- ordinal: "ordinal",
349
- }[unit.toLowerCase()];
350
-
351
- if (!normalized) throw new InvalidUnitError(unit);
352
-
353
- return normalized;
354
- }
355
-
356
- function normalizeUnitWithLocalWeeks(unit) {
357
- switch (unit.toLowerCase()) {
358
- case "localweekday":
359
- case "localweekdays":
360
- return "localWeekday";
361
- case "localweeknumber":
362
- case "localweeknumbers":
363
- return "localWeekNumber";
364
- case "localweekyear":
365
- case "localweekyears":
366
- return "localWeekYear";
367
- default:
368
- return normalizeUnit(unit);
369
- }
370
- }
371
-
372
- // this is a dumbed down version of fromObject() that runs about 60% faster
373
- // but doesn't do any validation, makes a bunch of assumptions about what units
374
- // are present, and so on.
375
- function quickDT(obj, opts) {
376
- const zone = normalizeZone(opts.zone, Settings.defaultZone),
377
- loc = Locale.fromObject(opts),
378
- tsNow = Settings.now();
379
-
380
- let ts, o;
381
-
382
- // assume we have the higher-order units
383
- if (!isUndefined(obj.year)) {
384
- for (const u of orderedUnits) {
385
- if (isUndefined(obj[u])) {
386
- obj[u] = defaultUnitValues[u];
387
- }
388
- }
389
-
390
- const invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
391
- if (invalid) {
392
- return DateTime.invalid(invalid);
393
- }
394
-
395
- const offsetProvis = zone.offset(tsNow);
396
- [ts, o] = objToTS(obj, offsetProvis, zone);
397
- } else {
398
- ts = tsNow;
399
- }
400
-
401
- return new DateTime({ ts, zone, loc, o });
402
- }
403
-
404
- function diffRelative(start, end, opts) {
405
- const round = isUndefined(opts.round) ? true : opts.round,
406
- format = (c, unit) => {
407
- c = roundTo(c, round || opts.calendary ? 0 : 2, true);
408
- const formatter = end.loc.clone(opts).relFormatter(opts);
409
- return formatter.format(c, unit);
410
- },
411
- differ = (unit) => {
412
- if (opts.calendary) {
413
- if (!end.hasSame(start, unit)) {
414
- return end.startOf(unit).diff(start.startOf(unit), unit).get(unit);
415
- } else return 0;
416
- } else {
417
- return end.diff(start, unit).get(unit);
418
- }
419
- };
420
-
421
- if (opts.unit) {
422
- return format(differ(opts.unit), opts.unit);
423
- }
424
-
425
- for (const unit of opts.units) {
426
- const count = differ(unit);
427
- if (Math.abs(count) >= 1) {
428
- return format(count, unit);
429
- }
430
- }
431
- return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
432
- }
433
-
434
- function lastOpts(argList) {
435
- let opts = {},
436
- args;
437
- if (argList.length > 0 && typeof argList[argList.length - 1] === "object") {
438
- opts = argList[argList.length - 1];
439
- args = Array.from(argList).slice(0, argList.length - 1);
440
- } else {
441
- args = Array.from(argList);
442
- }
443
- return [opts, args];
444
- }
445
-
446
- /**
447
- * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
448
- *
449
- * A DateTime comprises of:
450
- * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch.
451
- * * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone).
452
- * * Configuration properties that effect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`.
453
- *
454
- * Here is a brief overview of the most commonly used functionality it provides:
455
- *
456
- * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
457
- * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month},
458
- * {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
459
- * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
460
- * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors.
461
- * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}.
462
- * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, {@link DateTime#toMillis} and {@link DateTime#toJSDate}.
463
- *
464
- * There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation.
465
- */
466
- export default class DateTime {
467
- /**
468
- * @access private
469
- */
470
- constructor(config) {
471
- const zone = config.zone || Settings.defaultZone;
472
-
473
- let invalid =
474
- config.invalid ||
475
- (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) ||
476
- (!zone.isValid ? unsupportedZone(zone) : null);
477
- /**
478
- * @access private
479
- */
480
- this.ts = isUndefined(config.ts) ? Settings.now() : config.ts;
481
-
482
- let c = null,
483
- o = null;
484
- if (!invalid) {
485
- const unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
486
-
487
- if (unchanged) {
488
- [c, o] = [config.old.c, config.old.o];
489
- } else {
490
- const ot = zone.offset(this.ts);
491
- c = tsToObj(this.ts, ot);
492
- invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
493
- c = invalid ? null : c;
494
- o = invalid ? null : ot;
495
- }
496
- }
497
-
498
- /**
499
- * @access private
500
- */
501
- this._zone = zone;
502
- /**
503
- * @access private
504
- */
505
- this.loc = config.loc || Locale.create();
506
- /**
507
- * @access private
508
- */
509
- this.invalid = invalid;
510
- /**
511
- * @access private
512
- */
513
- this.weekData = null;
514
- /**
515
- * @access private
516
- */
517
- this.localWeekData = null;
518
- /**
519
- * @access private
520
- */
521
- this.c = c;
522
- /**
523
- * @access private
524
- */
525
- this.o = o;
526
- /**
527
- * @access private
528
- */
529
- this.isLuxonDateTime = true;
530
- }
531
-
532
- // CONSTRUCT
533
-
534
- /**
535
- * Create a DateTime for the current instant, in the system's time zone.
536
- *
537
- * Use Settings to override these default values if needed.
538
- * @example DateTime.now().toISO() //~> now in the ISO format
539
- * @return {DateTime}
540
- */
541
- static now() {
542
- return new DateTime({});
543
- }
544
-
545
- /**
546
- * Create a local DateTime
547
- * @param {number} [year] - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used
548
- * @param {number} [month=1] - The month, 1-indexed
549
- * @param {number} [day=1] - The day of the month, 1-indexed
550
- * @param {number} [hour=0] - The hour of the day, in 24-hour time
551
- * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
552
- * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
553
- * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
554
- * @example DateTime.local() //~> now
555
- * @example DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time
556
- * @example DateTime.local(2017) //~> 2017-01-01T00:00:00
557
- * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
558
- * @example DateTime.local(2017, 3, 12, { locale: "fr" }) //~> 2017-03-12T00:00:00, with a French locale
559
- * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
560
- * @example DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC
561
- * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
562
- * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
563
- * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
564
- * @return {DateTime}
565
- */
566
- static local() {
567
- const [opts, args] = lastOpts(arguments),
568
- [year, month, day, hour, minute, second, millisecond] = args;
569
- return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
570
- }
571
-
572
- /**
573
- * Create a DateTime in UTC
574
- * @param {number} [year] - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used
575
- * @param {number} [month=1] - The month, 1-indexed
576
- * @param {number} [day=1] - The day of the month
577
- * @param {number} [hour=0] - The hour of the day, in 24-hour time
578
- * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
579
- * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
580
- * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
581
- * @param {Object} options - configuration options for the DateTime
582
- * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
583
- * @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
584
- * @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
585
- * @example DateTime.utc() //~> now
586
- * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
587
- * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
588
- * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
589
- * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
590
- * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
591
- * @example DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" }) //~> 2017-03-12T05:45:00Z with a French locale
592
- * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
593
- * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr" }) //~> 2017-03-12T05:45:10.765Z with a French locale
594
- * @return {DateTime}
595
- */
596
- static utc() {
597
- const [opts, args] = lastOpts(arguments),
598
- [year, month, day, hour, minute, second, millisecond] = args;
599
-
600
- opts.zone = FixedOffsetZone.utcInstance;
601
- return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
602
- }
603
-
604
- /**
605
- * Create a DateTime from a JavaScript Date object. Uses the default zone.
606
- * @param {Date} date - a JavaScript Date object
607
- * @param {Object} options - configuration options for the DateTime
608
- * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
609
- * @return {DateTime}
610
- */
611
- static fromJSDate(date, options = {}) {
612
- const ts = isDate(date) ? date.valueOf() : NaN;
613
- if (Number.isNaN(ts)) {
614
- return DateTime.invalid("invalid input");
615
- }
616
-
617
- const zoneToUse = normalizeZone(options.zone, Settings.defaultZone);
618
- if (!zoneToUse.isValid) {
619
- return DateTime.invalid(unsupportedZone(zoneToUse));
620
- }
621
-
622
- return new DateTime({
623
- ts: ts,
624
- zone: zoneToUse,
625
- loc: Locale.fromObject(options),
626
- });
627
- }
628
-
629
- /**
630
- * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
631
- * @param {number} milliseconds - a number of milliseconds since 1970 UTC
632
- * @param {Object} options - configuration options for the DateTime
633
- * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
634
- * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
635
- * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
636
- * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
637
- * @return {DateTime}
638
- */
639
- static fromMillis(milliseconds, options = {}) {
640
- if (!isNumber(milliseconds)) {
641
- throw new InvalidArgumentError(
642
- `fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
643
- );
644
- } else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
645
- // this isn't perfect because because we can still end up out of range because of additional shifting, but it's a start
646
- return DateTime.invalid("Timestamp out of range");
647
- } else {
648
- return new DateTime({
649
- ts: milliseconds,
650
- zone: normalizeZone(options.zone, Settings.defaultZone),
651
- loc: Locale.fromObject(options),
652
- });
653
- }
654
- }
655
-
656
- /**
657
- * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
658
- * @param {number} seconds - a number of seconds since 1970 UTC
659
- * @param {Object} options - configuration options for the DateTime
660
- * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
661
- * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
662
- * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
663
- * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
664
- * @return {DateTime}
665
- */
666
- static fromSeconds(seconds, options = {}) {
667
- if (!isNumber(seconds)) {
668
- throw new InvalidArgumentError("fromSeconds requires a numerical input");
669
- } else {
670
- return new DateTime({
671
- ts: seconds * 1000,
672
- zone: normalizeZone(options.zone, Settings.defaultZone),
673
- loc: Locale.fromObject(options),
674
- });
675
- }
676
- }
677
-
678
- /**
679
- * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
680
- * @param {Object} obj - the object to create the DateTime from
681
- * @param {number} obj.year - a year, such as 1987
682
- * @param {number} obj.month - a month, 1-12
683
- * @param {number} obj.day - a day of the month, 1-31, depending on the month
684
- * @param {number} obj.ordinal - day of the year, 1-365 or 366
685
- * @param {number} obj.weekYear - an ISO week year
686
- * @param {number} obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year
687
- * @param {number} obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
688
- * @param {number} obj.localWeekYear - a week year, according to the locale
689
- * @param {number} obj.localWeekNumber - a week number, between 1 and 52 or 53, depending on the year, according to the locale
690
- * @param {number} obj.localWeekday - a weekday, 1-7, where 1 is the first and 7 is the last day of the week, according to the locale
691
- * @param {number} obj.hour - hour of the day, 0-23
692
- * @param {number} obj.minute - minute of the hour, 0-59
693
- * @param {number} obj.second - second of the minute, 0-59
694
- * @param {number} obj.millisecond - millisecond of the second, 0-999
695
- * @param {Object} opts - options for creating this DateTime
696
- * @param {string|Zone} [opts.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone()
697
- * @param {string} [opts.locale='system\'s locale'] - a locale to set on the resulting DateTime instance
698
- * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
699
- * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
700
- * @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
701
- * @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
702
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
703
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }),
704
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' })
705
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' })
706
- * @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
707
- * @example DateTime.fromObject({ localWeekYear: 2022, localWeekNumber: 1, localWeekday: 1 }, { locale: "en-US" }).toISODate() //=> '2021-12-26'
708
- * @return {DateTime}
709
- */
710
- static fromObject(obj, opts = {}) {
711
- obj = obj || {};
712
- const zoneToUse = normalizeZone(opts.zone, Settings.defaultZone);
713
- if (!zoneToUse.isValid) {
714
- return DateTime.invalid(unsupportedZone(zoneToUse));
715
- }
716
-
717
- const loc = Locale.fromObject(opts);
718
- const normalized = normalizeObject(obj, normalizeUnitWithLocalWeeks);
719
- const { minDaysInFirstWeek, startOfWeek } = usesLocalWeekValues(normalized, loc);
720
-
721
- const tsNow = Settings.now(),
722
- offsetProvis = !isUndefined(opts.specificOffset)
723
- ? opts.specificOffset
724
- : zoneToUse.offset(tsNow),
725
- containsOrdinal = !isUndefined(normalized.ordinal),
726
- containsGregorYear = !isUndefined(normalized.year),
727
- containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
728
- containsGregor = containsGregorYear || containsGregorMD,
729
- definiteWeekDef = normalized.weekYear || normalized.weekNumber;
730
-
731
- // cases:
732
- // just a weekday -> this week's instance of that weekday, no worries
733
- // (gregorian data or ordinal) + (weekYear or weekNumber) -> error
734
- // (gregorian month or day) + ordinal -> error
735
- // otherwise just use weeks or ordinals or gregorian, depending on what's specified
736
-
737
- if ((containsGregor || containsOrdinal) && definiteWeekDef) {
738
- throw new ConflictingSpecificationError(
739
- "Can't mix weekYear/weekNumber units with year/month/day or ordinals"
740
- );
741
- }
742
-
743
- if (containsGregorMD && containsOrdinal) {
744
- throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
745
- }
746
-
747
- const useWeekData = definiteWeekDef || (normalized.weekday && !containsGregor);
748
-
749
- // configure ourselves to deal with gregorian dates or week stuff
750
- let units,
751
- defaultValues,
752
- objNow = tsToObj(tsNow, offsetProvis);
753
- if (useWeekData) {
754
- units = orderedWeekUnits;
755
- defaultValues = defaultWeekUnitValues;
756
- objNow = gregorianToWeek(objNow, minDaysInFirstWeek, startOfWeek);
757
- } else if (containsOrdinal) {
758
- units = orderedOrdinalUnits;
759
- defaultValues = defaultOrdinalUnitValues;
760
- objNow = gregorianToOrdinal(objNow);
761
- } else {
762
- units = orderedUnits;
763
- defaultValues = defaultUnitValues;
764
- }
765
-
766
- // set default values for missing stuff
767
- let foundFirst = false;
768
- for (const u of units) {
769
- const v = normalized[u];
770
- if (!isUndefined(v)) {
771
- foundFirst = true;
772
- } else if (foundFirst) {
773
- normalized[u] = defaultValues[u];
774
- } else {
775
- normalized[u] = objNow[u];
776
- }
777
- }
778
-
779
- // make sure the values we have are in range
780
- const higherOrderInvalid = useWeekData
781
- ? hasInvalidWeekData(normalized, minDaysInFirstWeek, startOfWeek)
782
- : containsOrdinal
783
- ? hasInvalidOrdinalData(normalized)
784
- : hasInvalidGregorianData(normalized),
785
- invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
786
-
787
- if (invalid) {
788
- return DateTime.invalid(invalid);
789
- }
790
-
791
- // compute the actual time
792
- const gregorian = useWeekData
793
- ? weekToGregorian(normalized, minDaysInFirstWeek, startOfWeek)
794
- : containsOrdinal
795
- ? ordinalToGregorian(normalized)
796
- : normalized,
797
- [tsFinal, offsetFinal] = objToTS(gregorian, offsetProvis, zoneToUse),
798
- inst = new DateTime({
799
- ts: tsFinal,
800
- zone: zoneToUse,
801
- o: offsetFinal,
802
- loc,
803
- });
804
-
805
- // gregorian data + weekday serves only to validate
806
- if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
807
- return DateTime.invalid(
808
- "mismatched weekday",
809
- `you can't specify both a weekday of ${normalized.weekday} and a date of ${inst.toISO()}`
810
- );
811
- }
812
-
813
- return inst;
814
- }
815
-
816
- /**
817
- * Create a DateTime from an ISO 8601 string
818
- * @param {string} text - the ISO string
819
- * @param {Object} opts - options to affect the creation
820
- * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone
821
- * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
822
- * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
823
- * @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance
824
- * @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance
825
- * @example DateTime.fromISO('2016-05-25T09:08:34.123')
826
- * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
827
- * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
828
- * @example DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})
829
- * @example DateTime.fromISO('2016-W05-4')
830
- * @return {DateTime}
831
- */
832
- static fromISO(text, opts = {}) {
833
- const [vals, parsedZone] = parseISODate(text);
834
- return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text);
835
- }
836
-
837
- /**
838
- * Create a DateTime from an RFC 2822 string
839
- * @param {string} text - the RFC 2822 string
840
- * @param {Object} opts - options to affect the creation
841
- * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
842
- * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
843
- * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
844
- * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
845
- * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
846
- * @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
847
- * @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
848
- * @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
849
- * @return {DateTime}
850
- */
851
- static fromRFC2822(text, opts = {}) {
852
- const [vals, parsedZone] = parseRFC2822Date(text);
853
- return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text);
854
- }
855
-
856
- /**
857
- * Create a DateTime from an HTTP header date
858
- * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
859
- * @param {string} text - the HTTP header date
860
- * @param {Object} opts - options to affect the creation
861
- * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
862
- * @param {boolean} [opts.setZone=false] - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods.
863
- * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
864
- * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
865
- * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
866
- * @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
867
- * @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
868
- * @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
869
- * @return {DateTime}
870
- */
871
- static fromHTTP(text, opts = {}) {
872
- const [vals, parsedZone] = parseHTTPDate(text);
873
- return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
874
- }
875
-
876
- /**
877
- * Create a DateTime from an input string and format string.
878
- * Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).
879
- * @param {string} text - the string to parse
880
- * @param {string} fmt - the format the string is expected to be in (see the link below for the formats)
881
- * @param {Object} opts - options to affect the creation
882
- * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
883
- * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
884
- * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
885
- * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
886
- * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
887
- * @return {DateTime}
888
- */
889
- static fromFormat(text, fmt, opts = {}) {
890
- if (isUndefined(text) || isUndefined(fmt)) {
891
- throw new InvalidArgumentError("fromFormat requires an input string and a format");
892
- }
893
-
894
- const { locale = null, numberingSystem = null } = opts,
895
- localeToUse = Locale.fromOpts({
896
- locale,
897
- numberingSystem,
898
- defaultToEN: true,
899
- }),
900
- [vals, parsedZone, specificOffset, invalid] = parseFromTokens(localeToUse, text, fmt);
901
- if (invalid) {
902
- return DateTime.invalid(invalid);
903
- } else {
904
- return parseDataToDateTime(vals, parsedZone, opts, `format ${fmt}`, text, specificOffset);
905
- }
906
- }
907
-
908
- /**
909
- * @deprecated use fromFormat instead
910
- */
911
- static fromString(text, fmt, opts = {}) {
912
- return DateTime.fromFormat(text, fmt, opts);
913
- }
914
-
915
- /**
916
- * Create a DateTime from a SQL date, time, or datetime
917
- * Defaults to en-US if no locale has been specified, regardless of the system's locale
918
- * @param {string} text - the string to parse
919
- * @param {Object} opts - options to affect the creation
920
- * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
921
- * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
922
- * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
923
- * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
924
- * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
925
- * @example DateTime.fromSQL('2017-05-15')
926
- * @example DateTime.fromSQL('2017-05-15 09:12:34')
927
- * @example DateTime.fromSQL('2017-05-15 09:12:34.342')
928
- * @example DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')
929
- * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')
930
- * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })
931
- * @example DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })
932
- * @example DateTime.fromSQL('09:12:34.342')
933
- * @return {DateTime}
934
- */
935
- static fromSQL(text, opts = {}) {
936
- const [vals, parsedZone] = parseSQL(text);
937
- return parseDataToDateTime(vals, parsedZone, opts, "SQL", text);
938
- }
939
-
940
- /**
941
- * Create an invalid DateTime.
942
- * @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent.
943
- * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
944
- * @return {DateTime}
945
- */
946
- static invalid(reason, explanation = null) {
947
- if (!reason) {
948
- throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
949
- }
950
-
951
- const invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
952
-
953
- if (Settings.throwOnInvalid) {
954
- throw new InvalidDateTimeError(invalid);
955
- } else {
956
- return new DateTime({ invalid });
957
- }
958
- }
959
-
960
- /**
961
- * Check if an object is an instance of DateTime. Works across context boundaries
962
- * @param {object} o
963
- * @return {boolean}
964
- */
965
- static isDateTime(o) {
966
- return (o && o.isLuxonDateTime) || false;
967
- }
968
-
969
- /**
970
- * Produce the format string for a set of options
971
- * @param formatOpts
972
- * @param localeOpts
973
- * @returns {string}
974
- */
975
- static parseFormatForOpts(formatOpts, localeOpts = {}) {
976
- const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
977
- return !tokenList ? null : tokenList.map((t) => (t ? t.val : null)).join("");
978
- }
979
-
980
- /**
981
- * Produce the the fully expanded format token for the locale
982
- * Does NOT quote characters, so quoted tokens will not round trip correctly
983
- * @param fmt
984
- * @param localeOpts
985
- * @returns {string}
986
- */
987
- static expandFormat(fmt, localeOpts = {}) {
988
- const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
989
- return expanded.map((t) => t.val).join("");
990
- }
991
-
992
- // INFO
993
-
994
- /**
995
- * Get the value of unit.
996
- * @param {string} unit - a unit such as 'minute' or 'day'
997
- * @example DateTime.local(2017, 7, 4).get('month'); //=> 7
998
- * @example DateTime.local(2017, 7, 4).get('day'); //=> 4
999
- * @return {number}
1000
- */
1001
- get(unit) {
1002
- return this[unit];
1003
- }
1004
-
1005
- /**
1006
- * Returns whether the DateTime is valid. Invalid DateTimes occur when:
1007
- * * The DateTime was created from invalid calendar information, such as the 13th month or February 30
1008
- * * The DateTime was created by an operation on another invalid date
1009
- * @type {boolean}
1010
- */
1011
- get isValid() {
1012
- return this.invalid === null;
1013
- }
1014
-
1015
- /**
1016
- * Returns an error code if this DateTime is invalid, or null if the DateTime is valid
1017
- * @type {string}
1018
- */
1019
- get invalidReason() {
1020
- return this.invalid ? this.invalid.reason : null;
1021
- }
1022
-
1023
- /**
1024
- * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid
1025
- * @type {string}
1026
- */
1027
- get invalidExplanation() {
1028
- return this.invalid ? this.invalid.explanation : null;
1029
- }
1030
-
1031
- /**
1032
- * Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
1033
- *
1034
- * @type {string}
1035
- */
1036
- get locale() {
1037
- return this.isValid ? this.loc.locale : null;
1038
- }
1039
-
1040
- /**
1041
- * Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
1042
- *
1043
- * @type {string}
1044
- */
1045
- get numberingSystem() {
1046
- return this.isValid ? this.loc.numberingSystem : null;
1047
- }
1048
-
1049
- /**
1050
- * Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
1051
- *
1052
- * @type {string}
1053
- */
1054
- get outputCalendar() {
1055
- return this.isValid ? this.loc.outputCalendar : null;
1056
- }
1057
-
1058
- /**
1059
- * Get the time zone associated with this DateTime.
1060
- * @type {Zone}
1061
- */
1062
- get zone() {
1063
- return this._zone;
1064
- }
1065
-
1066
- /**
1067
- * Get the name of the time zone.
1068
- * @type {string}
1069
- */
1070
- get zoneName() {
1071
- return this.isValid ? this.zone.name : null;
1072
- }
1073
-
1074
- /**
1075
- * Get the year
1076
- * @example DateTime.local(2017, 5, 25).year //=> 2017
1077
- * @type {number}
1078
- */
1079
- get year() {
1080
- return this.isValid ? this.c.year : NaN;
1081
- }
1082
-
1083
- /**
1084
- * Get the quarter
1085
- * @example DateTime.local(2017, 5, 25).quarter //=> 2
1086
- * @type {number}
1087
- */
1088
- get quarter() {
1089
- return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
1090
- }
1091
-
1092
- /**
1093
- * Get the month (1-12).
1094
- * @example DateTime.local(2017, 5, 25).month //=> 5
1095
- * @type {number}
1096
- */
1097
- get month() {
1098
- return this.isValid ? this.c.month : NaN;
1099
- }
1100
-
1101
- /**
1102
- * Get the day of the month (1-30ish).
1103
- * @example DateTime.local(2017, 5, 25).day //=> 25
1104
- * @type {number}
1105
- */
1106
- get day() {
1107
- return this.isValid ? this.c.day : NaN;
1108
- }
1109
-
1110
- /**
1111
- * Get the hour of the day (0-23).
1112
- * @example DateTime.local(2017, 5, 25, 9).hour //=> 9
1113
- * @type {number}
1114
- */
1115
- get hour() {
1116
- return this.isValid ? this.c.hour : NaN;
1117
- }
1118
-
1119
- /**
1120
- * Get the minute of the hour (0-59).
1121
- * @example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
1122
- * @type {number}
1123
- */
1124
- get minute() {
1125
- return this.isValid ? this.c.minute : NaN;
1126
- }
1127
-
1128
- /**
1129
- * Get the second of the minute (0-59).
1130
- * @example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
1131
- * @type {number}
1132
- */
1133
- get second() {
1134
- return this.isValid ? this.c.second : NaN;
1135
- }
1136
-
1137
- /**
1138
- * Get the millisecond of the second (0-999).
1139
- * @example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
1140
- * @type {number}
1141
- */
1142
- get millisecond() {
1143
- return this.isValid ? this.c.millisecond : NaN;
1144
- }
1145
-
1146
- /**
1147
- * Get the week year
1148
- * @see https://en.wikipedia.org/wiki/ISO_week_date
1149
- * @example DateTime.local(2014, 12, 31).weekYear //=> 2015
1150
- * @type {number}
1151
- */
1152
- get weekYear() {
1153
- return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
1154
- }
1155
-
1156
- /**
1157
- * Get the week number of the week year (1-52ish).
1158
- * @see https://en.wikipedia.org/wiki/ISO_week_date
1159
- * @example DateTime.local(2017, 5, 25).weekNumber //=> 21
1160
- * @type {number}
1161
- */
1162
- get weekNumber() {
1163
- return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
1164
- }
1165
-
1166
- /**
1167
- * Get the day of the week.
1168
- * 1 is Monday and 7 is Sunday
1169
- * @see https://en.wikipedia.org/wiki/ISO_week_date
1170
- * @example DateTime.local(2014, 11, 31).weekday //=> 4
1171
- * @type {number}
1172
- */
1173
- get weekday() {
1174
- return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
1175
- }
1176
-
1177
- /**
1178
- * Returns true if this date is on a weekend according to the locale, false otherwise
1179
- * @returns {boolean}
1180
- */
1181
- get isWeekend() {
1182
- return this.isValid && this.loc.getWeekendDays().includes(this.weekday);
1183
- }
1184
-
1185
- /**
1186
- * Get the day of the week according to the locale.
1187
- * 1 is the first day of the week and 7 is the last day of the week.
1188
- * If the locale assigns Sunday as the first day of the week, then a date which is a Sunday will return 1,
1189
- * @returns {number}
1190
- */
1191
- get localWeekday() {
1192
- return this.isValid ? possiblyCachedLocalWeekData(this).weekday : NaN;
1193
- }
1194
-
1195
- /**
1196
- * Get the week number of the week year according to the locale. Different locales assign week numbers differently,
1197
- * because the week can start on different days of the week (see localWeekday) and because a different number of days
1198
- * is required for a week to count as the first week of a year.
1199
- * @returns {number}
1200
- */
1201
- get localWeekNumber() {
1202
- return this.isValid ? possiblyCachedLocalWeekData(this).weekNumber : NaN;
1203
- }
1204
-
1205
- /**
1206
- * Get the week year according to the locale. Different locales assign week numbers (and therefor week years)
1207
- * differently, see localWeekNumber.
1208
- * @returns {number}
1209
- */
1210
- get localWeekYear() {
1211
- return this.isValid ? possiblyCachedLocalWeekData(this).weekYear : NaN;
1212
- }
1213
-
1214
- /**
1215
- * Get the ordinal (meaning the day of the year)
1216
- * @example DateTime.local(2017, 5, 25).ordinal //=> 145
1217
- * @type {number|DateTime}
1218
- */
1219
- get ordinal() {
1220
- return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
1221
- }
1222
-
1223
- /**
1224
- * Get the human readable short month name, such as 'Oct'.
1225
- * Defaults to the system's locale if no locale has been specified
1226
- * @example DateTime.local(2017, 10, 30).monthShort //=> Oct
1227
- * @type {string}
1228
- */
1229
- get monthShort() {
1230
- return this.isValid ? Info.months("short", { locObj: this.loc })[this.month - 1] : null;
1231
- }
1232
-
1233
- /**
1234
- * Get the human readable long month name, such as 'October'.
1235
- * Defaults to the system's locale if no locale has been specified
1236
- * @example DateTime.local(2017, 10, 30).monthLong //=> October
1237
- * @type {string}
1238
- */
1239
- get monthLong() {
1240
- return this.isValid ? Info.months("long", { locObj: this.loc })[this.month - 1] : null;
1241
- }
1242
-
1243
- /**
1244
- * Get the human readable short weekday, such as 'Mon'.
1245
- * Defaults to the system's locale if no locale has been specified
1246
- * @example DateTime.local(2017, 10, 30).weekdayShort //=> Mon
1247
- * @type {string}
1248
- */
1249
- get weekdayShort() {
1250
- return this.isValid ? Info.weekdays("short", { locObj: this.loc })[this.weekday - 1] : null;
1251
- }
1252
-
1253
- /**
1254
- * Get the human readable long weekday, such as 'Monday'.
1255
- * Defaults to the system's locale if no locale has been specified
1256
- * @example DateTime.local(2017, 10, 30).weekdayLong //=> Monday
1257
- * @type {string}
1258
- */
1259
- get weekdayLong() {
1260
- return this.isValid ? Info.weekdays("long", { locObj: this.loc })[this.weekday - 1] : null;
1261
- }
1262
-
1263
- /**
1264
- * Get the UTC offset of this DateTime in minutes
1265
- * @example DateTime.now().offset //=> -240
1266
- * @example DateTime.utc().offset //=> 0
1267
- * @type {number}
1268
- */
1269
- get offset() {
1270
- return this.isValid ? +this.o : NaN;
1271
- }
1272
-
1273
- /**
1274
- * Get the short human name for the zone's current offset, for example "EST" or "EDT".
1275
- * Defaults to the system's locale if no locale has been specified
1276
- * @type {string}
1277
- */
1278
- get offsetNameShort() {
1279
- if (this.isValid) {
1280
- return this.zone.offsetName(this.ts, {
1281
- format: "short",
1282
- locale: this.locale,
1283
- });
1284
- } else {
1285
- return null;
1286
- }
1287
- }
1288
-
1289
- /**
1290
- * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time".
1291
- * Defaults to the system's locale if no locale has been specified
1292
- * @type {string}
1293
- */
1294
- get offsetNameLong() {
1295
- if (this.isValid) {
1296
- return this.zone.offsetName(this.ts, {
1297
- format: "long",
1298
- locale: this.locale,
1299
- });
1300
- } else {
1301
- return null;
1302
- }
1303
- }
1304
-
1305
- /**
1306
- * Get whether this zone's offset ever changes, as in a DST.
1307
- * @type {boolean}
1308
- */
1309
- get isOffsetFixed() {
1310
- return this.isValid ? this.zone.isUniversal : null;
1311
- }
1312
-
1313
- /**
1314
- * Get whether the DateTime is in a DST.
1315
- * @type {boolean}
1316
- */
1317
- get isInDST() {
1318
- if (this.isOffsetFixed) {
1319
- return false;
1320
- } else {
1321
- return (
1322
- this.offset > this.set({ month: 1, day: 1 }).offset ||
1323
- this.offset > this.set({ month: 5 }).offset
1324
- );
1325
- }
1326
- }
1327
-
1328
- /**
1329
- * Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC
1330
- * in this DateTime's zone. During DST changes local time can be ambiguous, for example
1331
- * `2023-10-29T02:30:00` in `Europe/Berlin` can have offset `+01:00` or `+02:00`.
1332
- * This method will return both possible DateTimes if this DateTime's local time is ambiguous.
1333
- * @returns {DateTime[]}
1334
- */
1335
- getPossibleOffsets() {
1336
- if (!this.isValid || this.isOffsetFixed) {
1337
- return [this];
1338
- }
1339
- const dayMs = 86400000;
1340
- const minuteMs = 60000;
1341
- const localTS = objToLocalTS(this.c);
1342
- const oEarlier = this.zone.offset(localTS - dayMs);
1343
- const oLater = this.zone.offset(localTS + dayMs);
1344
-
1345
- const o1 = this.zone.offset(localTS - oEarlier * minuteMs);
1346
- const o2 = this.zone.offset(localTS - oLater * minuteMs);
1347
- if (o1 === o2) {
1348
- return [this];
1349
- }
1350
- const ts1 = localTS - o1 * minuteMs;
1351
- const ts2 = localTS - o2 * minuteMs;
1352
- const c1 = tsToObj(ts1, o1);
1353
- const c2 = tsToObj(ts2, o2);
1354
- if (
1355
- c1.hour === c2.hour &&
1356
- c1.minute === c2.minute &&
1357
- c1.second === c2.second &&
1358
- c1.millisecond === c2.millisecond
1359
- ) {
1360
- return [clone(this, { ts: ts1 }), clone(this, { ts: ts2 })];
1361
- }
1362
- return [this];
1363
- }
1364
-
1365
- /**
1366
- * Returns true if this DateTime is in a leap year, false otherwise
1367
- * @example DateTime.local(2016).isInLeapYear //=> true
1368
- * @example DateTime.local(2013).isInLeapYear //=> false
1369
- * @type {boolean}
1370
- */
1371
- get isInLeapYear() {
1372
- return isLeapYear(this.year);
1373
- }
1374
-
1375
- /**
1376
- * Returns the number of days in this DateTime's month
1377
- * @example DateTime.local(2016, 2).daysInMonth //=> 29
1378
- * @example DateTime.local(2016, 3).daysInMonth //=> 31
1379
- * @type {number}
1380
- */
1381
- get daysInMonth() {
1382
- return daysInMonth(this.year, this.month);
1383
- }
1384
-
1385
- /**
1386
- * Returns the number of days in this DateTime's year
1387
- * @example DateTime.local(2016).daysInYear //=> 366
1388
- * @example DateTime.local(2013).daysInYear //=> 365
1389
- * @type {number}
1390
- */
1391
- get daysInYear() {
1392
- return this.isValid ? daysInYear(this.year) : NaN;
1393
- }
1394
-
1395
- /**
1396
- * Returns the number of weeks in this DateTime's year
1397
- * @see https://en.wikipedia.org/wiki/ISO_week_date
1398
- * @example DateTime.local(2004).weeksInWeekYear //=> 53
1399
- * @example DateTime.local(2013).weeksInWeekYear //=> 52
1400
- * @type {number}
1401
- */
1402
- get weeksInWeekYear() {
1403
- return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
1404
- }
1405
-
1406
- /**
1407
- * Returns the number of weeks in this DateTime's local week year
1408
- * @example DateTime.local(2020, 6, {locale: 'en-US'}).weeksInLocalWeekYear //=> 52
1409
- * @example DateTime.local(2020, 6, {locale: 'de-DE'}).weeksInLocalWeekYear //=> 53
1410
- * @type {number}
1411
- */
1412
- get weeksInLocalWeekYear() {
1413
- return this.isValid
1414
- ? weeksInWeekYear(
1415
- this.localWeekYear,
1416
- this.loc.getMinDaysInFirstWeek(),
1417
- this.loc.getStartOfWeek()
1418
- )
1419
- : NaN;
1420
- }
1421
-
1422
- /**
1423
- * Returns the resolved Intl options for this DateTime.
1424
- * This is useful in understanding the behavior of formatting methods
1425
- * @param {Object} opts - the same options as toLocaleString
1426
- * @return {Object}
1427
- */
1428
- resolvedLocaleOptions(opts = {}) {
1429
- const { locale, numberingSystem, calendar } = Formatter.create(
1430
- this.loc.clone(opts),
1431
- opts
1432
- ).resolvedOptions(this);
1433
- return { locale, numberingSystem, outputCalendar: calendar };
1434
- }
1435
-
1436
- // TRANSFORM
1437
-
1438
- /**
1439
- * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
1440
- *
1441
- * Equivalent to {@link DateTime#setZone}('utc')
1442
- * @param {number} [offset=0] - optionally, an offset from UTC in minutes
1443
- * @param {Object} [opts={}] - options to pass to `setZone()`
1444
- * @return {DateTime}
1445
- */
1446
- toUTC(offset = 0, opts = {}) {
1447
- return this.setZone(FixedOffsetZone.instance(offset), opts);
1448
- }
1449
-
1450
- /**
1451
- * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.
1452
- *
1453
- * Equivalent to `setZone('local')`
1454
- * @return {DateTime}
1455
- */
1456
- toLocal() {
1457
- return this.setZone(Settings.defaultZone);
1458
- }
1459
-
1460
- /**
1461
- * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
1462
- *
1463
- * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link DateTime#plus}. You may wish to use {@link DateTime#toLocal} and {@link DateTime#toUTC} which provide simple convenience wrappers for commonly used zones.
1464
- * @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link DateTime#Zone} class.
1465
- * @param {Object} opts - options
1466
- * @param {boolean} [opts.keepLocalTime=false] - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this.
1467
- * @return {DateTime}
1468
- */
1469
- setZone(zone, { keepLocalTime = false, keepCalendarTime = false } = {}) {
1470
- zone = normalizeZone(zone, Settings.defaultZone);
1471
- if (zone.equals(this.zone)) {
1472
- return this;
1473
- } else if (!zone.isValid) {
1474
- return DateTime.invalid(unsupportedZone(zone));
1475
- } else {
1476
- let newTS = this.ts;
1477
- if (keepLocalTime || keepCalendarTime) {
1478
- const offsetGuess = zone.offset(this.ts);
1479
- const asObj = this.toObject();
1480
- [newTS] = objToTS(asObj, offsetGuess, zone);
1481
- }
1482
- return clone(this, { ts: newTS, zone });
1483
- }
1484
- }
1485
-
1486
- /**
1487
- * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
1488
- * @param {Object} properties - the properties to set
1489
- * @example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
1490
- * @return {DateTime}
1491
- */
1492
- reconfigure({ locale, numberingSystem, outputCalendar } = {}) {
1493
- const loc = this.loc.clone({ locale, numberingSystem, outputCalendar });
1494
- return clone(this, { loc });
1495
- }
1496
-
1497
- /**
1498
- * "Set" the locale. Returns a newly-constructed DateTime.
1499
- * Just a convenient alias for reconfigure({ locale })
1500
- * @example DateTime.local(2017, 5, 25).setLocale('en-GB')
1501
- * @return {DateTime}
1502
- */
1503
- setLocale(locale) {
1504
- return this.reconfigure({ locale });
1505
- }
1506
-
1507
- /**
1508
- * "Set" the values of specified units. Returns a newly-constructed DateTime.
1509
- * You can only set units with this method; for "setting" metadata, see {@link DateTime#reconfigure} and {@link DateTime#setZone}.
1510
- *
1511
- * This method also supports setting locale-based week units, i.e. `localWeekday`, `localWeekNumber` and `localWeekYear`.
1512
- * They cannot be mixed with ISO-week units like `weekday`.
1513
- * @param {Object} values - a mapping of units to numbers
1514
- * @example dt.set({ year: 2017 })
1515
- * @example dt.set({ hour: 8, minute: 30 })
1516
- * @example dt.set({ weekday: 5 })
1517
- * @example dt.set({ year: 2005, ordinal: 234 })
1518
- * @return {DateTime}
1519
- */
1520
- set(values) {
1521
- if (!this.isValid) return this;
1522
-
1523
- const normalized = normalizeObject(values, normalizeUnitWithLocalWeeks);
1524
- const { minDaysInFirstWeek, startOfWeek } = usesLocalWeekValues(normalized, this.loc);
1525
-
1526
- const settingWeekStuff =
1527
- !isUndefined(normalized.weekYear) ||
1528
- !isUndefined(normalized.weekNumber) ||
1529
- !isUndefined(normalized.weekday),
1530
- containsOrdinal = !isUndefined(normalized.ordinal),
1531
- containsGregorYear = !isUndefined(normalized.year),
1532
- containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
1533
- containsGregor = containsGregorYear || containsGregorMD,
1534
- definiteWeekDef = normalized.weekYear || normalized.weekNumber;
1535
-
1536
- if ((containsGregor || containsOrdinal) && definiteWeekDef) {
1537
- throw new ConflictingSpecificationError(
1538
- "Can't mix weekYear/weekNumber units with year/month/day or ordinals"
1539
- );
1540
- }
1541
-
1542
- if (containsGregorMD && containsOrdinal) {
1543
- throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
1544
- }
1545
-
1546
- let mixed;
1547
- if (settingWeekStuff) {
1548
- mixed = weekToGregorian(
1549
- { ...gregorianToWeek(this.c, minDaysInFirstWeek, startOfWeek), ...normalized },
1550
- minDaysInFirstWeek,
1551
- startOfWeek
1552
- );
1553
- } else if (!isUndefined(normalized.ordinal)) {
1554
- mixed = ordinalToGregorian({ ...gregorianToOrdinal(this.c), ...normalized });
1555
- } else {
1556
- mixed = { ...this.toObject(), ...normalized };
1557
-
1558
- // if we didn't set the day but we ended up on an overflow date,
1559
- // use the last day of the right month
1560
- if (isUndefined(normalized.day)) {
1561
- mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
1562
- }
1563
- }
1564
-
1565
- const [ts, o] = objToTS(mixed, this.o, this.zone);
1566
- return clone(this, { ts, o });
1567
- }
1568
-
1569
- /**
1570
- * Add a period of time to this DateTime and return the resulting DateTime
1571
- *
1572
- * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between.
1573
- * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
1574
- * @example DateTime.now().plus(123) //~> in 123 milliseconds
1575
- * @example DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes
1576
- * @example DateTime.now().plus({ days: 1 }) //~> this time tomorrow
1577
- * @example DateTime.now().plus({ days: -1 }) //~> this time yesterday
1578
- * @example DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min
1579
- * @example DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min
1580
- * @return {DateTime}
1581
- */
1582
- plus(duration) {
1583
- if (!this.isValid) return this;
1584
- const dur = Duration.fromDurationLike(duration);
1585
- return clone(this, adjustTime(this, dur));
1586
- }
1587
-
1588
- /**
1589
- * Subtract a period of time to this DateTime and return the resulting DateTime
1590
- * See {@link DateTime#plus}
1591
- * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
1592
- @return {DateTime}
1593
- */
1594
- minus(duration) {
1595
- if (!this.isValid) return this;
1596
- const dur = Duration.fromDurationLike(duration).negate();
1597
- return clone(this, adjustTime(this, dur));
1598
- }
1599
-
1600
- /**
1601
- * "Set" this DateTime to the beginning of a unit of time.
1602
- * @param {string} unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
1603
- * @param {Object} opts - options
1604
- * @param {boolean} [opts.useLocaleWeeks=false] - If true, use weeks based on the locale, i.e. use the locale-dependent start of the week
1605
- * @example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'
1606
- * @example DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'
1607
- * @example DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays
1608
- * @example DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'
1609
- * @example DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'
1610
- * @return {DateTime}
1611
- */
1612
- startOf(unit, { useLocaleWeeks = false } = {}) {
1613
- if (!this.isValid) return this;
1614
-
1615
- const o = {},
1616
- normalizedUnit = Duration.normalizeUnit(unit);
1617
- switch (normalizedUnit) {
1618
- case "years":
1619
- o.month = 1;
1620
- // falls through
1621
- case "quarters":
1622
- case "months":
1623
- o.day = 1;
1624
- // falls through
1625
- case "weeks":
1626
- case "days":
1627
- o.hour = 0;
1628
- // falls through
1629
- case "hours":
1630
- o.minute = 0;
1631
- // falls through
1632
- case "minutes":
1633
- o.second = 0;
1634
- // falls through
1635
- case "seconds":
1636
- o.millisecond = 0;
1637
- break;
1638
- case "milliseconds":
1639
- break;
1640
- // no default, invalid units throw in normalizeUnit()
1641
- }
1642
-
1643
- if (normalizedUnit === "weeks") {
1644
- if (useLocaleWeeks) {
1645
- const startOfWeek = this.loc.getStartOfWeek();
1646
- const { weekday } = this;
1647
- if (weekday < startOfWeek) {
1648
- o.weekNumber = this.weekNumber - 1;
1649
- }
1650
- o.weekday = startOfWeek;
1651
- } else {
1652
- o.weekday = 1;
1653
- }
1654
- }
1655
-
1656
- if (normalizedUnit === "quarters") {
1657
- const q = Math.ceil(this.month / 3);
1658
- o.month = (q - 1) * 3 + 1;
1659
- }
1660
-
1661
- return this.set(o);
1662
- }
1663
-
1664
- /**
1665
- * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time
1666
- * @param {string} unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
1667
- * @param {Object} opts - options
1668
- * @param {boolean} [opts.useLocaleWeeks=false] - If true, use weeks based on the locale, i.e. use the locale-dependent start of the week
1669
- * @example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'
1670
- * @example DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'
1671
- * @example DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays
1672
- * @example DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'
1673
- * @example DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'
1674
- * @return {DateTime}
1675
- */
1676
- endOf(unit, opts) {
1677
- return this.isValid
1678
- ? this.plus({ [unit]: 1 })
1679
- .startOf(unit, opts)
1680
- .minus(1)
1681
- : this;
1682
- }
1683
-
1684
- // OUTPUT
1685
-
1686
- /**
1687
- * Returns a string representation of this DateTime formatted according to the specified format string.
1688
- * **You may not want this.** See {@link DateTime#toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens).
1689
- * Defaults to en-US if no locale has been specified, regardless of the system's locale.
1690
- * @param {string} fmt - the format string
1691
- * @param {Object} opts - opts to override the configuration options on this DateTime
1692
- * @example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
1693
- * @example DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
1694
- * @example DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
1695
- * @example DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'
1696
- * @return {string}
1697
- */
1698
- toFormat(fmt, opts = {}) {
1699
- return this.isValid
1700
- ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt)
1701
- : INVALID;
1702
- }
1703
-
1704
- /**
1705
- * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE`.
1706
- * The exact behavior of this method is browser-specific, but in general it will return an appropriate representation
1707
- * of the DateTime in the assigned locale.
1708
- * Defaults to the system's locale if no locale has been specified
1709
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
1710
- * @param formatOpts {Object} - Intl.DateTimeFormat constructor options and configuration options
1711
- * @param {Object} opts - opts to override the configuration options on this DateTime
1712
- * @example DateTime.now().toLocaleString(); //=> 4/20/2017
1713
- * @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
1714
- * @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
1715
- * @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
1716
- * @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
1717
- * @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
1718
- * @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
1719
- * @example DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
1720
- * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32'
1721
- * @return {string}
1722
- */
1723
- toLocaleString(formatOpts = Formats.DATE_SHORT, opts = {}) {
1724
- return this.isValid
1725
- ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this)
1726
- : INVALID;
1727
- }
1728
-
1729
- /**
1730
- * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output.
1731
- * Defaults to the system's locale if no locale has been specified
1732
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts
1733
- * @param opts {Object} - Intl.DateTimeFormat constructor options, same as `toLocaleString`.
1734
- * @example DateTime.now().toLocaleParts(); //=> [
1735
- * //=> { type: 'day', value: '25' },
1736
- * //=> { type: 'literal', value: '/' },
1737
- * //=> { type: 'month', value: '05' },
1738
- * //=> { type: 'literal', value: '/' },
1739
- * //=> { type: 'year', value: '1982' }
1740
- * //=> ]
1741
- */
1742
- toLocaleParts(opts = {}) {
1743
- return this.isValid
1744
- ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this)
1745
- : [];
1746
- }
1747
-
1748
- /**
1749
- * Returns an ISO 8601-compliant string representation of this DateTime
1750
- * @param {Object} opts - options
1751
- * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
1752
- * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
1753
- * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
1754
- * @param {boolean} [opts.extendedZone=false] - add the time zone format extension
1755
- * @param {string} [opts.format='extended'] - choose between the basic and extended format
1756
- * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
1757
- * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
1758
- * @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
1759
- * @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
1760
- * @return {string}
1761
- */
1762
- toISO({
1763
- format = "extended",
1764
- suppressSeconds = false,
1765
- suppressMilliseconds = false,
1766
- includeOffset = true,
1767
- extendedZone = false,
1768
- } = {}) {
1769
- if (!this.isValid) {
1770
- return null;
1771
- }
1772
-
1773
- const ext = format === "extended";
1774
-
1775
- let c = toISODate(this, ext);
1776
- c += "T";
1777
- c += toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone);
1778
- return c;
1779
- }
1780
-
1781
- /**
1782
- * Returns an ISO 8601-compliant string representation of this DateTime's date component
1783
- * @param {Object} opts - options
1784
- * @param {string} [opts.format='extended'] - choose between the basic and extended format
1785
- * @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
1786
- * @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
1787
- * @return {string}
1788
- */
1789
- toISODate({ format = "extended" } = {}) {
1790
- if (!this.isValid) {
1791
- return null;
1792
- }
1793
-
1794
- return toISODate(this, format === "extended");
1795
- }
1796
-
1797
- /**
1798
- * Returns an ISO 8601-compliant string representation of this DateTime's week date
1799
- * @example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'
1800
- * @return {string}
1801
- */
1802
- toISOWeekDate() {
1803
- return toTechFormat(this, "kkkk-'W'WW-c");
1804
- }
1805
-
1806
- /**
1807
- * Returns an ISO 8601-compliant string representation of this DateTime's time component
1808
- * @param {Object} opts - options
1809
- * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
1810
- * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
1811
- * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
1812
- * @param {boolean} [opts.extendedZone=true] - add the time zone format extension
1813
- * @param {boolean} [opts.includePrefix=false] - include the `T` prefix
1814
- * @param {string} [opts.format='extended'] - choose between the basic and extended format
1815
- * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
1816
- * @example DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
1817
- * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'
1818
- * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'
1819
- * @return {string}
1820
- */
1821
- toISOTime({
1822
- suppressMilliseconds = false,
1823
- suppressSeconds = false,
1824
- includeOffset = true,
1825
- includePrefix = false,
1826
- extendedZone = false,
1827
- format = "extended",
1828
- } = {}) {
1829
- if (!this.isValid) {
1830
- return null;
1831
- }
1832
-
1833
- let c = includePrefix ? "T" : "";
1834
- return (
1835
- c +
1836
- toISOTime(
1837
- this,
1838
- format === "extended",
1839
- suppressSeconds,
1840
- suppressMilliseconds,
1841
- includeOffset,
1842
- extendedZone
1843
- )
1844
- );
1845
- }
1846
-
1847
- /**
1848
- * Returns an RFC 2822-compatible string representation of this DateTime
1849
- * @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
1850
- * @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
1851
- * @return {string}
1852
- */
1853
- toRFC2822() {
1854
- return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
1855
- }
1856
-
1857
- /**
1858
- * Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT.
1859
- * Specifically, the string conforms to RFC 1123.
1860
- * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
1861
- * @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
1862
- * @example DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'
1863
- * @return {string}
1864
- */
1865
- toHTTP() {
1866
- return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
1867
- }
1868
-
1869
- /**
1870
- * Returns a string representation of this DateTime appropriate for use in SQL Date
1871
- * @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
1872
- * @return {string}
1873
- */
1874
- toSQLDate() {
1875
- if (!this.isValid) {
1876
- return null;
1877
- }
1878
- return toISODate(this, true);
1879
- }
1880
-
1881
- /**
1882
- * Returns a string representation of this DateTime appropriate for use in SQL Time
1883
- * @param {Object} opts - options
1884
- * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
1885
- * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
1886
- * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
1887
- * @example DateTime.utc().toSQL() //=> '05:15:16.345'
1888
- * @example DateTime.now().toSQL() //=> '05:15:16.345 -04:00'
1889
- * @example DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'
1890
- * @example DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
1891
- * @return {string}
1892
- */
1893
- toSQLTime({ includeOffset = true, includeZone = false, includeOffsetSpace = true } = {}) {
1894
- let fmt = "HH:mm:ss.SSS";
1895
-
1896
- if (includeZone || includeOffset) {
1897
- if (includeOffsetSpace) {
1898
- fmt += " ";
1899
- }
1900
- if (includeZone) {
1901
- fmt += "z";
1902
- } else if (includeOffset) {
1903
- fmt += "ZZ";
1904
- }
1905
- }
1906
-
1907
- return toTechFormat(this, fmt, true);
1908
- }
1909
-
1910
- /**
1911
- * Returns a string representation of this DateTime appropriate for use in SQL DateTime
1912
- * @param {Object} opts - options
1913
- * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
1914
- * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
1915
- * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
1916
- * @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
1917
- * @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
1918
- * @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
1919
- * @example DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'
1920
- * @return {string}
1921
- */
1922
- toSQL(opts = {}) {
1923
- if (!this.isValid) {
1924
- return null;
1925
- }
1926
-
1927
- return `${this.toSQLDate()} ${this.toSQLTime(opts)}`;
1928
- }
1929
-
1930
- /**
1931
- * Returns a string representation of this DateTime appropriate for debugging
1932
- * @return {string}
1933
- */
1934
- toString() {
1935
- return this.isValid ? this.toISO() : INVALID;
1936
- }
1937
-
1938
- /**
1939
- * Returns a string representation of this DateTime appropriate for the REPL.
1940
- * @return {string}
1941
- */
1942
- [Symbol.for("nodejs.util.inspect.custom")]() {
1943
- if (this.isValid) {
1944
- return `DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`;
1945
- } else {
1946
- return `DateTime { Invalid, reason: ${this.invalidReason} }`;
1947
- }
1948
- }
1949
-
1950
- /**
1951
- * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime#toMillis}
1952
- * @return {number}
1953
- */
1954
- valueOf() {
1955
- return this.toMillis();
1956
- }
1957
-
1958
- /**
1959
- * Returns the epoch milliseconds of this DateTime.
1960
- * @return {number}
1961
- */
1962
- toMillis() {
1963
- return this.isValid ? this.ts : NaN;
1964
- }
1965
-
1966
- /**
1967
- * Returns the epoch seconds of this DateTime.
1968
- * @return {number}
1969
- */
1970
- toSeconds() {
1971
- return this.isValid ? this.ts / 1000 : NaN;
1972
- }
1973
-
1974
- /**
1975
- * Returns the epoch seconds (as a whole number) of this DateTime.
1976
- * @return {number}
1977
- */
1978
- toUnixInteger() {
1979
- return this.isValid ? Math.floor(this.ts / 1000) : NaN;
1980
- }
1981
-
1982
- /**
1983
- * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
1984
- * @return {string}
1985
- */
1986
- toJSON() {
1987
- return this.toISO();
1988
- }
1989
-
1990
- /**
1991
- * Returns a BSON serializable equivalent to this DateTime.
1992
- * @return {Date}
1993
- */
1994
- toBSON() {
1995
- return this.toJSDate();
1996
- }
1997
-
1998
- /**
1999
- * Returns a JavaScript object with this DateTime's year, month, day, and so on.
2000
- * @param opts - options for generating the object
2001
- * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
2002
- * @example DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
2003
- * @return {Object}
2004
- */
2005
- toObject(opts = {}) {
2006
- if (!this.isValid) return {};
2007
-
2008
- const base = { ...this.c };
2009
-
2010
- if (opts.includeConfig) {
2011
- base.outputCalendar = this.outputCalendar;
2012
- base.numberingSystem = this.loc.numberingSystem;
2013
- base.locale = this.loc.locale;
2014
- }
2015
- return base;
2016
- }
2017
-
2018
- /**
2019
- * Returns a JavaScript Date equivalent to this DateTime.
2020
- * @return {Date}
2021
- */
2022
- toJSDate() {
2023
- return new Date(this.isValid ? this.ts : NaN);
2024
- }
2025
-
2026
- // COMPARE
2027
-
2028
- /**
2029
- * Return the difference between two DateTimes as a Duration.
2030
- * @param {DateTime} otherDateTime - the DateTime to compare this one to
2031
- * @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration.
2032
- * @param {Object} opts - options that affect the creation of the Duration
2033
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
2034
- * @example
2035
- * var i1 = DateTime.fromISO('1982-05-25T09:45'),
2036
- * i2 = DateTime.fromISO('1983-10-14T10:30');
2037
- * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 }
2038
- * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 }
2039
- * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 }
2040
- * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 }
2041
- * @return {Duration}
2042
- */
2043
- diff(otherDateTime, unit = "milliseconds", opts = {}) {
2044
- if (!this.isValid || !otherDateTime.isValid) {
2045
- return Duration.invalid("created by diffing an invalid DateTime");
2046
- }
2047
-
2048
- const durOpts = { locale: this.locale, numberingSystem: this.numberingSystem, ...opts };
2049
-
2050
- const units = maybeArray(unit).map(Duration.normalizeUnit),
2051
- otherIsLater = otherDateTime.valueOf() > this.valueOf(),
2052
- earlier = otherIsLater ? this : otherDateTime,
2053
- later = otherIsLater ? otherDateTime : this,
2054
- diffed = diff(earlier, later, units, durOpts);
2055
-
2056
- return otherIsLater ? diffed.negate() : diffed;
2057
- }
2058
-
2059
- /**
2060
- * Return the difference between this DateTime and right now.
2061
- * See {@link DateTime#diff}
2062
- * @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration
2063
- * @param {Object} opts - options that affect the creation of the Duration
2064
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
2065
- * @return {Duration}
2066
- */
2067
- diffNow(unit = "milliseconds", opts = {}) {
2068
- return this.diff(DateTime.now(), unit, opts);
2069
- }
2070
-
2071
- /**
2072
- * Return an Interval spanning between this DateTime and another DateTime
2073
- * @param {DateTime} otherDateTime - the other end point of the Interval
2074
- * @return {Interval}
2075
- */
2076
- until(otherDateTime) {
2077
- return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
2078
- }
2079
-
2080
- /**
2081
- * Return whether this DateTime is in the same unit of time as another DateTime.
2082
- * Higher-order units must also be identical for this function to return `true`.
2083
- * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime#setZone} to convert one of the dates if needed.
2084
- * @param {DateTime} otherDateTime - the other DateTime
2085
- * @param {string} unit - the unit of time to check sameness on
2086
- * @param {Object} opts - options
2087
- * @param {boolean} [opts.useLocaleWeeks=false] - If true, use weeks based on the locale, i.e. use the locale-dependent start of the week; only the locale of this DateTime is used
2088
- * @example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
2089
- * @return {boolean}
2090
- */
2091
- hasSame(otherDateTime, unit, opts) {
2092
- if (!this.isValid) return false;
2093
-
2094
- const inputMs = otherDateTime.valueOf();
2095
- const adjustedToZone = this.setZone(otherDateTime.zone, { keepLocalTime: true });
2096
- return (
2097
- adjustedToZone.startOf(unit, opts) <= inputMs && inputMs <= adjustedToZone.endOf(unit, opts)
2098
- );
2099
- }
2100
-
2101
- /**
2102
- * Equality check
2103
- * Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid.
2104
- * To compare just the millisecond values, use `+dt1 === +dt2`.
2105
- * @param {DateTime} other - the other DateTime
2106
- * @return {boolean}
2107
- */
2108
- equals(other) {
2109
- return (
2110
- this.isValid &&
2111
- other.isValid &&
2112
- this.valueOf() === other.valueOf() &&
2113
- this.zone.equals(other.zone) &&
2114
- this.loc.equals(other.loc)
2115
- );
2116
- }
2117
-
2118
- /**
2119
- * Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
2120
- * platform supports Intl.RelativeTimeFormat. Rounds down by default.
2121
- * @param {Object} options - options that affect the output
2122
- * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
2123
- * @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow"
2124
- * @param {string|string[]} options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"
2125
- * @param {boolean} [options.round=true] - whether to round the numbers in the output.
2126
- * @param {number} [options.padding=0] - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding.
2127
- * @param {string} options.locale - override the locale of this DateTime
2128
- * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
2129
- * @example DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day"
2130
- * @example DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"
2131
- * @example DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"
2132
- * @example DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago"
2133
- * @example DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"
2134
- * @example DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"
2135
- */
2136
- toRelative(options = {}) {
2137
- if (!this.isValid) return null;
2138
- const base = options.base || DateTime.fromObject({}, { zone: this.zone }),
2139
- padding = options.padding ? (this < base ? -options.padding : options.padding) : 0;
2140
- let units = ["years", "months", "days", "hours", "minutes", "seconds"];
2141
- let unit = options.unit;
2142
- if (Array.isArray(options.unit)) {
2143
- units = options.unit;
2144
- unit = undefined;
2145
- }
2146
- return diffRelative(base, this.plus(padding), {
2147
- ...options,
2148
- numeric: "always",
2149
- units,
2150
- unit,
2151
- });
2152
- }
2153
-
2154
- /**
2155
- * Returns a string representation of this date relative to today, such as "yesterday" or "next month".
2156
- * Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
2157
- * @param {Object} options - options that affect the output
2158
- * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
2159
- * @param {string} options.locale - override the locale of this DateTime
2160
- * @param {string} options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days"
2161
- * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
2162
- * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"
2163
- * @example DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana"
2164
- * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"
2165
- * @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
2166
- */
2167
- toRelativeCalendar(options = {}) {
2168
- if (!this.isValid) return null;
2169
-
2170
- return diffRelative(options.base || DateTime.fromObject({}, { zone: this.zone }), this, {
2171
- ...options,
2172
- numeric: "auto",
2173
- units: ["years", "months", "days"],
2174
- calendary: true,
2175
- });
2176
- }
2177
-
2178
- /**
2179
- * Return the min of several date times
2180
- * @param {...DateTime} dateTimes - the DateTimes from which to choose the minimum
2181
- * @return {DateTime} the min DateTime, or undefined if called with no argument
2182
- */
2183
- static min(...dateTimes) {
2184
- if (!dateTimes.every(DateTime.isDateTime)) {
2185
- throw new InvalidArgumentError("min requires all arguments be DateTimes");
2186
- }
2187
- return bestBy(dateTimes, (i) => i.valueOf(), Math.min);
2188
- }
2189
-
2190
- /**
2191
- * Return the max of several date times
2192
- * @param {...DateTime} dateTimes - the DateTimes from which to choose the maximum
2193
- * @return {DateTime} the max DateTime, or undefined if called with no argument
2194
- */
2195
- static max(...dateTimes) {
2196
- if (!dateTimes.every(DateTime.isDateTime)) {
2197
- throw new InvalidArgumentError("max requires all arguments be DateTimes");
2198
- }
2199
- return bestBy(dateTimes, (i) => i.valueOf(), Math.max);
2200
- }
2201
-
2202
- // MISC
2203
-
2204
- /**
2205
- * Explain how a string would be parsed by fromFormat()
2206
- * @param {string} text - the string to parse
2207
- * @param {string} fmt - the format the string is expected to be in (see description)
2208
- * @param {Object} options - options taken by fromFormat()
2209
- * @return {Object}
2210
- */
2211
- static fromFormatExplain(text, fmt, options = {}) {
2212
- const { locale = null, numberingSystem = null } = options,
2213
- localeToUse = Locale.fromOpts({
2214
- locale,
2215
- numberingSystem,
2216
- defaultToEN: true,
2217
- });
2218
- return explainFromTokens(localeToUse, text, fmt);
2219
- }
2220
-
2221
- /**
2222
- * @deprecated use fromFormatExplain instead
2223
- */
2224
- static fromStringExplain(text, fmt, options = {}) {
2225
- return DateTime.fromFormatExplain(text, fmt, options);
2226
- }
2227
-
2228
- // FORMAT PRESETS
2229
-
2230
- /**
2231
- * {@link DateTime#toLocaleString} format like 10/14/1983
2232
- * @type {Object}
2233
- */
2234
- static get DATE_SHORT() {
2235
- return Formats.DATE_SHORT;
2236
- }
2237
-
2238
- /**
2239
- * {@link DateTime#toLocaleString} format like 'Oct 14, 1983'
2240
- * @type {Object}
2241
- */
2242
- static get DATE_MED() {
2243
- return Formats.DATE_MED;
2244
- }
2245
-
2246
- /**
2247
- * {@link DateTime#toLocaleString} format like 'Fri, Oct 14, 1983'
2248
- * @type {Object}
2249
- */
2250
- static get DATE_MED_WITH_WEEKDAY() {
2251
- return Formats.DATE_MED_WITH_WEEKDAY;
2252
- }
2253
-
2254
- /**
2255
- * {@link DateTime#toLocaleString} format like 'October 14, 1983'
2256
- * @type {Object}
2257
- */
2258
- static get DATE_FULL() {
2259
- return Formats.DATE_FULL;
2260
- }
2261
-
2262
- /**
2263
- * {@link DateTime#toLocaleString} format like 'Tuesday, October 14, 1983'
2264
- * @type {Object}
2265
- */
2266
- static get DATE_HUGE() {
2267
- return Formats.DATE_HUGE;
2268
- }
2269
-
2270
- /**
2271
- * {@link DateTime#toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
2272
- * @type {Object}
2273
- */
2274
- static get TIME_SIMPLE() {
2275
- return Formats.TIME_SIMPLE;
2276
- }
2277
-
2278
- /**
2279
- * {@link DateTime#toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
2280
- * @type {Object}
2281
- */
2282
- static get TIME_WITH_SECONDS() {
2283
- return Formats.TIME_WITH_SECONDS;
2284
- }
2285
-
2286
- /**
2287
- * {@link DateTime#toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
2288
- * @type {Object}
2289
- */
2290
- static get TIME_WITH_SHORT_OFFSET() {
2291
- return Formats.TIME_WITH_SHORT_OFFSET;
2292
- }
2293
-
2294
- /**
2295
- * {@link DateTime#toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
2296
- * @type {Object}
2297
- */
2298
- static get TIME_WITH_LONG_OFFSET() {
2299
- return Formats.TIME_WITH_LONG_OFFSET;
2300
- }
2301
-
2302
- /**
2303
- * {@link DateTime#toLocaleString} format like '09:30', always 24-hour.
2304
- * @type {Object}
2305
- */
2306
- static get TIME_24_SIMPLE() {
2307
- return Formats.TIME_24_SIMPLE;
2308
- }
2309
-
2310
- /**
2311
- * {@link DateTime#toLocaleString} format like '09:30:23', always 24-hour.
2312
- * @type {Object}
2313
- */
2314
- static get TIME_24_WITH_SECONDS() {
2315
- return Formats.TIME_24_WITH_SECONDS;
2316
- }
2317
-
2318
- /**
2319
- * {@link DateTime#toLocaleString} format like '09:30:23 EDT', always 24-hour.
2320
- * @type {Object}
2321
- */
2322
- static get TIME_24_WITH_SHORT_OFFSET() {
2323
- return Formats.TIME_24_WITH_SHORT_OFFSET;
2324
- }
2325
-
2326
- /**
2327
- * {@link DateTime#toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
2328
- * @type {Object}
2329
- */
2330
- static get TIME_24_WITH_LONG_OFFSET() {
2331
- return Formats.TIME_24_WITH_LONG_OFFSET;
2332
- }
2333
-
2334
- /**
2335
- * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
2336
- * @type {Object}
2337
- */
2338
- static get DATETIME_SHORT() {
2339
- return Formats.DATETIME_SHORT;
2340
- }
2341
-
2342
- /**
2343
- * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
2344
- * @type {Object}
2345
- */
2346
- static get DATETIME_SHORT_WITH_SECONDS() {
2347
- return Formats.DATETIME_SHORT_WITH_SECONDS;
2348
- }
2349
-
2350
- /**
2351
- * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
2352
- * @type {Object}
2353
- */
2354
- static get DATETIME_MED() {
2355
- return Formats.DATETIME_MED;
2356
- }
2357
-
2358
- /**
2359
- * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
2360
- * @type {Object}
2361
- */
2362
- static get DATETIME_MED_WITH_SECONDS() {
2363
- return Formats.DATETIME_MED_WITH_SECONDS;
2364
- }
2365
-
2366
- /**
2367
- * {@link DateTime#toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
2368
- * @type {Object}
2369
- */
2370
- static get DATETIME_MED_WITH_WEEKDAY() {
2371
- return Formats.DATETIME_MED_WITH_WEEKDAY;
2372
- }
2373
-
2374
- /**
2375
- * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
2376
- * @type {Object}
2377
- */
2378
- static get DATETIME_FULL() {
2379
- return Formats.DATETIME_FULL;
2380
- }
2381
-
2382
- /**
2383
- * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
2384
- * @type {Object}
2385
- */
2386
- static get DATETIME_FULL_WITH_SECONDS() {
2387
- return Formats.DATETIME_FULL_WITH_SECONDS;
2388
- }
2389
-
2390
- /**
2391
- * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
2392
- * @type {Object}
2393
- */
2394
- static get DATETIME_HUGE() {
2395
- return Formats.DATETIME_HUGE;
2396
- }
2397
-
2398
- /**
2399
- * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
2400
- * @type {Object}
2401
- */
2402
- static get DATETIME_HUGE_WITH_SECONDS() {
2403
- return Formats.DATETIME_HUGE_WITH_SECONDS;
2404
- }
2405
- }
2406
-
2407
- /**
2408
- * @private
2409
- */
2410
- export function friendlyDateTime(dateTimeish) {
2411
- if (DateTime.isDateTime(dateTimeish)) {
2412
- return dateTimeish;
2413
- } else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) {
2414
- return DateTime.fromJSDate(dateTimeish);
2415
- } else if (dateTimeish && typeof dateTimeish === "object") {
2416
- return DateTime.fromObject(dateTimeish);
2417
- } else {
2418
- throw new InvalidArgumentError(
2419
- `Unknown datetime argument: ${dateTimeish}, of type ${typeof dateTimeish}`
2420
- );
2421
- }
2422
- }