first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+542
View File
@@ -0,0 +1,542 @@
# Change Log - @fluentui/date-time-utilities
This log was last generated on Thu, 16 Oct 2025 07:19:27 GMT and should not be manually modified.
<!-- Start content -->
## [8.6.11](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.11)
Thu, 16 Oct 2025 07:19:27 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.10..@fluentui/date-time-utilities_v8.6.11)
### Patches
- style: resolve explicit-return tyle lint errors ([PR #35303](https://github.com/microsoft/fluentui/pull/35303) by martinhochel@microsoft.com)
## [8.6.10](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.10)
Fri, 21 Feb 2025 07:22:41 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.9..@fluentui/date-time-utilities_v8.6.10)
### Patches
- Bump @fluentui/set-version to v8.2.24 ([PR #33879](https://github.com/microsoft/fluentui/pull/33879) by beachball)
## [8.6.9](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.9)
Mon, 24 Jun 2024 07:33:22 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.8..@fluentui/date-time-utilities_v8.6.9)
### Patches
- Bump @fluentui/set-version to v8.2.23 ([commit](https://github.com/microsoft/fluentui/commit/444d2ef497b5be5b4252f4af86ded3d2db7a0850) by beachball)
## [8.6.8](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.8)
Thu, 06 Jun 2024 07:26:46 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.7..@fluentui/date-time-utilities_v8.6.8)
### Patches
- Bump @fluentui/set-version to v8.2.22 ([commit](https://github.com/microsoft/fluentui/commit/e5e806f46bd00bc7baffbfe7514a617600ba2d47) by beachball)
## [8.6.7](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.7)
Tue, 28 May 2024 07:28:20 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.6..@fluentui/date-time-utilities_v8.6.7)
### Patches
- Bump @fluentui/set-version to v8.2.21 ([PR #31324](https://github.com/microsoft/fluentui/pull/31324) by beachball)
## [8.6.6](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.6)
Fri, 24 May 2024 07:28:17 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.5..@fluentui/date-time-utilities_v8.6.6)
### Patches
- Bump @fluentui/set-version to v8.2.20 ([commit](https://github.com/microsoft/fluentui/commit/e5b614623b9aa1ae3f1f86f3e753b934943a4601) by beachball)
## [8.6.5](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.5)
Thu, 23 May 2024 07:28:51 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.4..@fluentui/date-time-utilities_v8.6.5)
### Patches
- Bump @fluentui/set-version to v8.2.19 ([commit](https://github.com/microsoft/fluentui/commit/10e6758b203de79c53ce31ba264e137f83f50ff4) by beachball)
## [8.6.4](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.4)
Mon, 20 May 2024 07:29:20 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.3..@fluentui/date-time-utilities_v8.6.4)
### Patches
- Bump @fluentui/set-version to v8.2.18 ([commit](https://github.com/microsoft/fluentui/commit/eadc00f974b3199e6c34d2e9d16015add154ec3b) by beachball)
## [8.6.3](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.3)
Wed, 24 Apr 2024 07:27:48 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.2..@fluentui/date-time-utilities_v8.6.3)
### Patches
- Bump @fluentui/set-version to v8.2.17 ([PR #31130](https://github.com/microsoft/fluentui/pull/31130) by beachball)
## [8.6.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.2)
Fri, 12 Apr 2024 07:29:11 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.1..@fluentui/date-time-utilities_v8.6.2)
### Patches
- Bump @fluentui/set-version to v8.2.16 ([PR #31022](https://github.com/microsoft/fluentui/pull/31022) by beachball)
## [8.6.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.1)
Wed, 03 Apr 2024 07:29:31 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.6.0..@fluentui/date-time-utilities_v8.6.1)
### Patches
- Bump @fluentui/set-version to v8.2.15 ([PR #30943](https://github.com/microsoft/fluentui/pull/30943) by beachball)
## [8.6.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.6.0)
Fri, 22 Mar 2024 07:28:52 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.16..@fluentui/date-time-utilities_v8.6.0)
### Minor changes
- fix: Build errors in TypeScript 5.3 ([PR #30807](https://github.com/microsoft/fluentui/pull/30807) by behowell@microsoft.com)
## [8.5.16](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.16)
Wed, 10 Jan 2024 07:28:50 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.15..@fluentui/date-time-utilities_v8.5.16)
### Patches
- Bump @fluentui/set-version to v8.2.14 ([PR #30063](https://github.com/microsoft/fluentui/pull/30063) by beachball)
## [8.5.15](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.15)
Thu, 14 Dec 2023 07:30:10 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.14..@fluentui/date-time-utilities_v8.5.15)
### Patches
- Bump @fluentui/set-version to v8.2.13 ([PR #30061](https://github.com/microsoft/fluentui/pull/30061) by beachball)
## [8.5.14](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.14)
Sat, 28 Oct 2023 00:29:16 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.13..@fluentui/date-time-utilities_v8.5.14)
### Patches
- Bump @fluentui/set-version to v8.2.12 ([commit](https://github.com/microsoft/fluentui/commit/70d0762fd12eb211f7c1dbe31a23b2fbb73a67c4) by beachball)
## [8.5.13](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.13)
Mon, 19 Jun 2023 07:36:39 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.12..@fluentui/date-time-utilities_v8.5.13)
### Patches
- chore: migrate to ts 4.7 which wont emit undefined anymore for optional arguments ([PR #28067](https://github.com/microsoft/fluentui/pull/28067) by martinhochel@microsoft.com)
## [8.5.12](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.12)
Wed, 31 May 2023 07:38:40 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.11..@fluentui/date-time-utilities_v8.5.12)
### Patches
- Bump @fluentui/set-version to v8.2.11 ([commit](https://github.com/microsoft/fluentui/commit/dd8c30d9b97f68eb332366fc0e69775a88775319) by beachball)
## [8.5.11](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.11)
Tue, 30 May 2023 07:36:09 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.10..@fluentui/date-time-utilities_v8.5.11)
### Patches
- Bump @fluentui/set-version to v8.2.10 ([PR #27685](https://github.com/microsoft/fluentui/pull/27685) by beachball)
## [8.5.10](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.10)
Fri, 05 May 2023 18:14:03 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.9..@fluentui/date-time-utilities_v8.5.10)
### Patches
- fix: explicitly ship dist/ folder. ([PR #27769](https://github.com/microsoft/fluentui/pull/27769) by tristan.watanabe@gmail.com)
- Bump @fluentui/set-version to v8.2.9 ([PR #27769](https://github.com/microsoft/fluentui/pull/27769) by beachball)
## [8.5.9](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.9)
Tue, 02 May 2023 00:58:14 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.8..@fluentui/date-time-utilities_v8.5.9)
### Patches
- fix: esm, cjs, and amd folders should all be published correctly. ([PR #27736](https://github.com/microsoft/fluentui/pull/27736) by tristan.watanabe@gmail.com)
- Bump @fluentui/set-version to v8.2.8 ([PR #27736](https://github.com/microsoft/fluentui/pull/27736) by beachball)
## [8.5.8](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.8)
Mon, 01 May 2023 07:39:54 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.7..@fluentui/date-time-utilities_v8.5.8)
### Patches
- Bump @fluentui/set-version to v8.2.7 ([PR #27724](https://github.com/microsoft/fluentui/pull/27724) by beachball)
## [8.5.7](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.7)
Tue, 25 Apr 2023 07:38:31 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.6..@fluentui/date-time-utilities_v8.5.7)
### Patches
- chore: Refactored getDateFromTimeSelection variable names. ([PR #26482](https://github.com/microsoft/fluentui/pull/26482) by jamwu@microsoft.com)
## [8.5.6](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.6)
Fri, 17 Mar 2023 08:15:56 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.5..@fluentui/date-time-utilities_v8.5.6)
### Patches
- Bump @fluentui/set-version to v8.2.6 ([PR #27210](https://github.com/microsoft/fluentui/pull/27210) by beachball)
## [8.5.5](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.5)
Fri, 03 Feb 2023 07:50:06 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.4..@fluentui/date-time-utilities_v8.5.5)
### Patches
- Bump @fluentui/set-version to v8.2.5 ([PR #26569](https://github.com/microsoft/fluentui/pull/26569) by beachball)
## [8.5.4](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.4)
Tue, 10 Jan 2023 07:50:15 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.3..@fluentui/date-time-utilities_v8.5.4)
### Patches
- Bump @fluentui/set-version to v8.2.4 ([PR #26260](https://github.com/microsoft/fluentui/pull/26260) by beachball)
## [8.5.3](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.3)
Wed, 09 Nov 2022 07:48:12 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.2..@fluentui/date-time-utilities_v8.5.3)
### Patches
- Bump @fluentui/set-version to v8.2.3 ([PR #25564](https://github.com/microsoft/fluentui/pull/25564) by beachball)
## [8.5.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.2)
Mon, 08 Aug 2022 07:39:33 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.1..@fluentui/date-time-utilities_v8.5.2)
### Patches
- Bump @fluentui/set-version to v8.2.2 ([PR #24212](https://github.com/microsoft/fluentui/pull/24212) by beachball)
## [8.5.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.1)
Fri, 13 May 2022 07:45:35 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.5.0..@fluentui/date-time-utilities_v8.5.1)
### Patches
- Bump @fluentui/set-version to v8.2.1 ([PR #22966](https://github.com/microsoft/fluentui/pull/22966) by beachball)
## [8.5.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.5.0)
Fri, 11 Mar 2022 19:51:47 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.4.0..@fluentui/date-time-utilities_v8.5.0)
### Minor changes
- Bump version to fix exports for partner team ([PR #22074](https://github.com/microsoft/fluentui/pull/22074) by gcox@microsoft.com)
### Patches
- Add compat exports to date-time-utilities ([PR #22063](https://github.com/microsoft/fluentui/pull/22063) by gcox@microsoft.com)
## [8.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.4.0)
Thu, 03 Mar 2022 07:24:25 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.3.0..@fluentui/date-time-utilities_v8.4.0)
### Minor changes
- Adding explicit export maps on all consumer packages for FUIR 8 and 9. ([PR #21508](https://github.com/microsoft/fluentui/pull/21508) by dzearing@microsoft.com)
- Bump @fluentui/set-version to v8.2.0 ([PR #21919](https://github.com/microsoft/fluentui/pull/21919) by beachball)
## [8.3.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.3.0)
Tue, 25 Jan 2022 07:30:05 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.2.3..@fluentui/date-time-utilities_v8.3.0)
### Minor changes
- Added getDateFromTimeSelection function, TimeConstant values OffsetTo24HourFormat and TimeFormatRegex ([PR #20805](https://github.com/microsoft/fluentui/pull/20805) by jamwu@microsoft.com)
## [8.2.3](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.2.3)
Thu, 25 Nov 2021 14:54:16 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.2.2..@fluentui/date-time-utilities_v8.2.3)
### Patches
- Bump @fluentui/set-version to v8.1.5 ([PR #20784](https://github.com/microsoft/fluentui/pull/20784) by beachball)
## [8.2.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.2.2)
Tue, 03 Aug 2021 07:39:30 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.2.1..@fluentui/date-time-utilities_v8.2.2)
### Patches
- Bump @fluentui/eslint-plugin to v1.3.3 ([PR #19169](https://github.com/microsoft/fluentui/pull/19169) by behowell@microsoft.com)
## [8.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.2.1)
Fri, 09 Jul 2021 07:39:31 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.2.0..@fluentui/date-time-utilities_v8.2.1)
### Patches
- Bump @fluentui/eslint-plugin to v1.3.2 ([PR #18808](https://github.com/microsoft/fluentui/pull/18808) by martinhochel@microsoft.com)
## [8.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.2.0)
Mon, 28 Jun 2021 07:35:16 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.1.2..@fluentui/date-time-utilities_v8.2.0)
### Minor changes
- Add functions for time related utils ([PR #18556](https://github.com/microsoft/fluentui/pull/18556) by shi.cheng@microsoft.com)
## [8.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.1.2)
Mon, 07 Jun 2021 07:38:15 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.1.1..@fluentui/date-time-utilities_v8.1.2)
### Patches
- Bump @fluentui/eslint-plugin to v1.3.1 ([PR #18437](https://github.com/microsoft/fluentui/pull/18437) by martinhochel@microsoft.com)
## [8.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.1.1)
Thu, 20 May 2021 07:41:54 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.1.0..@fluentui/date-time-utilities_v8.1.1)
### Patches
- Bump @fluentui/eslint-plugin to v1.3.0 ([PR #18024](https://github.com/microsoft/fluentui/pull/18024) by elcraig@microsoft.com)
## [8.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.1.0)
Fri, 30 Apr 2021 07:42:23 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.3..@fluentui/date-time-utilities_v8.1.0)
### Minor changes
- Upgrade to typescript 4.1.5 ([PR #17932](https://github.com/microsoft/fluentui/pull/17932) by joschect@microsoft.com)
### Patches
- Bump @fluentui/eslint-plugin to v1.2.0 ([PR #17932](https://github.com/microsoft/fluentui/pull/17932) by joschect@microsoft.com)
- Bump @fluentui/set-version to v8.1.0 ([PR #17932](https://github.com/microsoft/fluentui/pull/17932) by joschect@microsoft.com)
- Bump @fluentui/scripts to v1.0.0 ([PR #17932](https://github.com/microsoft/fluentui/pull/17932) by joschect@microsoft.com)
## [8.0.3](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.3)
Fri, 23 Apr 2021 07:37:10 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.2..@fluentui/date-time-utilities_v8.0.3)
### Patches
- Bump @fluentui/eslint-plugin to v1.1.1 ([PR #17894](https://github.com/microsoft/fluentui/pull/17894) by olfedias@microsoft.com)
## [8.0.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.2)
Wed, 31 Mar 2021 00:53:43 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.1..@fluentui/date-time-utilities_v8.0.2)
### Patches
- Bump @fluentui/eslint-plugin to v1.1.0 ([PR #17568](https://github.com/microsoft/fluentui/pull/17568) by elcraig@microsoft.com)
## [8.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.1)
Fri, 26 Feb 2021 01:16:27 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.0-beta.4..@fluentui/date-time-utilities_v8.0.1)
### Patches
- Release version 8 ([PR #17169](https://github.com/microsoft/fluentui/pull/17169) by elcraig@microsoft.com)
## [8.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.0-beta.4)
Thu, 18 Feb 2021 12:27:34 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.0-beta.3..@fluentui/date-time-utilities_v8.0.0-beta.4)
### Changes
- Bump @fluentui/eslint-plugin to v1.0.0-beta.2 ([PR #16975](https://github.com/microsoft/fluentui/pull/16975) by elcraig@microsoft.com)
## [8.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.0-beta.3)
Wed, 17 Feb 2021 12:21:39 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.0-beta.2..@fluentui/date-time-utilities_v8.0.0-beta.3)
### Changes
- add labels to calendar tables, date header button, and tweak label wording for conciseness ([PR #16855](https://github.com/microsoft/fluentui/pull/16855) by sarah.higley@microsoft.com)
## [8.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.0-beta.2)
Thu, 28 Jan 2021 12:25:56 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.0-beta.1..@fluentui/date-time-utilities_v8.0.0-beta.2)
### Changes
- Updating to webpack 5, latest typings, latest loaders and plugins. ([PR #16447](https://github.com/microsoft/fluentui/pull/16447) by dzearing@microsoft.com)
- Clean up some prop comments and deprecated messages ([PR #16555](https://github.com/microsoft/fluentui/pull/16555) by elcraig@microsoft.com)
## [8.0.0-beta.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.0-beta.1)
Mon, 07 Dec 2020 12:29:34 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v8.0.0-beta.0..@fluentui/date-time-utilities_v8.0.0-beta.1)
### Changes
- Remove northstar-specific types and utilities ([PR #16138](https://github.com/microsoft/fluentui/pull/16138) by elcraig@microsoft.com)
## [8.0.0-beta.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v8.0.0-beta.0)
Fri, 23 Oct 2020 03:26:15 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.9.0..@fluentui/date-time-utilities_v8.0.0-beta.0)
### Changes
- Add missing eslintrc, version.ts; Remove unneeded package dependencies. ([PR #15456](https://github.com/microsoft/fluentui/pull/15456) by xgao@microsoft.com)
- Rename @uifabric/set-version to @fluentui/set-version ([PR #15616](https://github.com/microsoft/fluentui/pull/15616) by ololubek@microsoft.com)
- Split out northstar-specific types in date-time-utilities ([PR #15644](https://github.com/microsoft/fluentui/pull/15644) by elcraig@microsoft.com)
## [7.9.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.9.0)
Thu, 24 Sep 2020 00:46:56 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.8.1..@fluentui/date-time-utilities_v7.9.0)
### Minor changes
- Removing calendarCellFormatString from date-time-utilities. ([PR #15062](https://github.com/microsoft/fluentui/pull/15062) by karymes@microsoft.com)
## [7.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.8.0)
Fri, 04 Sep 2020 12:28:23 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.7.0..@fluentui/date-time-utilities_v7.8.0)
### Minor changes
- Add helper function to compute end of week date, give a current date and starting day of week ([PR #14862](https://github.com/microsoft/fluentui/pull/14862) by pompomon@gmail.com)
## [7.7.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.7.0)
Wed, 02 Sep 2020 12:26:41 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.6.1..@fluentui/date-time-utilities_v7.7.0)
### Minor changes
- Adding more localization strings to fluentui/date-time-utilities package. ([PR #14816](https://github.com/microsoft/fluentui/pull/14816) by karymes@microsoft.com)
## [7.6.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.6.1)
Fri, 28 Aug 2020 12:29:20 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.6.0..@fluentui/date-time-utilities_v7.6.1)
### Patches
- fixing negative date navigation by changing the date clone method from using strings to using the date object itself ([PR #14647](https://github.com/microsoft/fluentui/pull/14647) by lorejoh12@gmail.com)
## [7.6.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.6.0)
Fri, 21 Aug 2020 12:34:55 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.5.0..@fluentui/date-time-utilities_v7.6.0)
### Minor changes
- Adding datepicker input placeholder string. ([PR #14621](https://github.com/microsoft/fluentui/pull/14621) by karymes@microsoft.com)
## [7.5.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.5.0)
Thu, 13 Aug 2020 12:41:58 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.4.1..@fluentui/date-time-utilities_v7.5.0)
### Minor changes
- Updating localization defaults and changing type of formatting functions ([PR #14486](https://github.com/microsoft/fluentui/pull/14486) by karymes@microsoft.com)
## [7.4.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.4.1)
Mon, 10 Aug 2020 06:19:21 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.4.0..@fluentui/date-time-utilities_v7.4.1)
### Patches
- date time utilities unit tests were timezone dependent, because the start date was right on the border between two months and when getting run locally the dates convert to local time zone. changing initial date fixes it ([PR #14395](https://github.com/microsoft/fluentui/pull/14395) by lorejoh12@gmail.com)
## [7.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.4.0)
Thu, 06 Aug 2020 00:30:40 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.3.0..@fluentui/date-time-utilities_v7.4.0)
### Minor changes
- Expose getDatePartHashValue utility ([PR #14030](https://github.com/microsoft/fluentui/pull/14030) by miclo@microsoft.com)
## [7.3.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.3.0)
Fri, 24 Jul 2020 12:45:55 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.2.0..@fluentui/date-time-utilities_v7.3.0)
### Minor changes
- adding isMarked to API to mark days in grid ([PR #14074](https://github.com/microsoft/fluentui/pull/14074) by lorejoh12@gmail.com)
## [7.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.2.0)
Thu, 23 Jul 2020 12:43:51 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.1.3..@fluentui/date-time-utilities_v7.2.0)
### Minor changes
- Extracting isContiguous days method into a separate file. Adding default localization strings. ([PR #14058](https://github.com/microsoft/fluentui/pull/14058) by karymes@microsoft.com)
## [7.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.1.0)
Fri, 19 Jun 2020 12:38:09 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/date-time-utilities_v7.0.1..@fluentui/date-time-utilities_v7.1.0)
### Minor changes
- Extract helper functions from date-time/Calendar ([PR #13640](https://github.com/microsoft/fluentui/pull/13640) by pompomon@gmail.com)
## [7.0.1](https://github.com/microsoft/fluentui/tree/@fluentui/date-time-utilities_v7.0.1)
Wed, 17 Jun 2020 12:37:16 GMT
### Patches
- Add Datetime utilities package ([PR #13605](https://github.com/microsoft/fluentui/pull/13605) by pompomon@gmail.com)
+15
View File
@@ -0,0 +1,15 @@
@fluentui/date-time-utilities
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
+7
View File
@@ -0,0 +1,7 @@
# @fluentui/date-time-utilities
**Date and time utilities for [Fluent UI](https://developer.microsoft.com/en-us/fluentui)**
This package includes a number of date and time utility functions used by Fluent UI React DatePicker and Calendar components.
See [GitHub](https://github.com/microsoft/fluentui) for more details on the Fluent UI React project and packages within.
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "@fluentui/scripts-api-extractor/api-extractor.common.json"
}
@@ -0,0 +1,582 @@
/**
* Returns a date offset from the given date by the specified number of days.
* @param date - The origin date
* @param days - The number of days to offset. 'days' can be negative.
* @returns A new Date object offset from the origin date by the given number of days
*/
export declare function addDays(date: Date, days: number): Date;
/**
* Returns a date offset from the given date by the specified number of minutes.
* @param date - The origin date
* @param minutes - The number of minutes to offset. 'minutes' can be negative.
* @returns A new Date object offset from the origin date by the given number of minutes
*/
export declare const addMinutes: (date: Date, minutes: number) => Date;
/**
* Returns a date offset from the given date by the specified number of months.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param months - The number of months to offset. 'months' can be negative.
* @returns A new Date object offset from the origin date by the given number of months
*/
export declare function addMonths(date: Date, months: number): Date;
/**
* Returns a date offset from the given date by the specified number of weeks.
* @param date - The origin date
* @param weeks - The number of weeks to offset. 'weeks' can be negative.
* @returns A new Date object offset from the origin date by the given number of weeks
*/
export declare function addWeeks(date: Date, weeks: number): Date;
/**
* Returns a date offset from the given date by the specified number of years.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param years - The number of years to offset. 'years' can be negative.
* @returns A new Date object offset from the origin date by the given number of years
*/
export declare function addYears(date: Date, years: number): Date;
/**
* Rounds the date's minute up to the next available increment. For example, if `date` has time 1:21
* and `increments` is 5, the resulting time will be 1:25.
* @param date - Date to ceil minutes
* @param increments - Time increments
* @returns Date with ceiled minute
*/
export declare const ceilMinuteToIncrement: (date: Date, increments: number) => Date;
/**
* Compare the date parts of two dates
* @param date1 - The first date to compare
* @param date2 - The second date to compare
* @returns A negative value if date1 is earlier than date2, 0 if the dates are equal, or a positive value
* if date1 is later than date2.
*/
export declare function compareDatePart(date1: Date, date2: Date): number;
/**
* Compares two dates, and returns true if the two dates (not accounting for time-of-day) are equal.
* @returns True if the two dates represent the same date (regardless of time-of-day), false otherwise.
*/
export declare function compareDates(date1: Date, date2: Date): boolean;
/**
* The supported date range types
* {@docCategory DateTimeUtilities}
*/
export declare enum DateRangeType {
Day = 0,
Week = 1,
Month = 2,
WorkWeek = 3
}
/**
* The days of the week
* {@docCategory DateTimeUtilities}
*/
export declare enum DayOfWeek {
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6
}
export declare const DAYS_IN_WEEK = 7;
export declare const DEFAULT_CALENDAR_STRINGS: ICalendarStrings;
export declare const DEFAULT_DATE_FORMATTING: IDateFormatting;
export declare const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings;
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
export declare const findAvailableDate: (options: IAvailableDateOptions) => Date | undefined;
/**
* First week of the year settings types
* {@docCategory DateTimeUtilities}
*/
export declare enum FirstWeekOfYear {
FirstDay = 0,
FirstFullWeek = 1,
FirstFourDayWeek = 2
}
/**
* Format date to a day string representation
* @param date - input date to format
*/
export declare const formatDay: (date: Date) => string;
/**
* Format date to a month string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month-day-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format a date object to a localized time string using the browser's default locale
* @param date - Input date to format
* @param showSeconds - Whether to show seconds in the formatted string
* @param useHour12 - Whether to use 12-hour time
*/
export declare const formatTimeString: (date: Date, showSeconds?: boolean, useHour12?: boolean) => string;
/**
* Format date to a year string representation
* @param date - input date to format
*/
export declare const formatYear: (date: Date) => string;
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
export declare const getBoundedDateRange: (dateRange: Date[], minDate?: Date, maxDate?: Date) => Date[];
/**
* Returns a date object from the selected time.
* @param useHour12 - If the time picker uses 12 or 24 hour formatting
* @param dateStartAnchor - The baseline date to calculate the offset of the selected time
* @param selectedTime - A string representing the user selected time
* @returns A new date object offset from the baseDate using the selected time.
*/
export declare const getDateFromTimeSelection: (useHour12: boolean, dateStartAnchor: Date, selectedTime: string) => Date;
/**
* Helper function to assist in date comparisons
*/
export declare function getDatePartHashValue(date: Date): number;
/**
* Gets the date range array including the specified date. The date range array is calculated as the list
* of dates accounting for the specified first day of the week and date range type.
* @param date - The input date
* @param dateRangeType - The desired date range type, i.e., day, week, month, etc.
* @param firstDayOfWeek - The first day of the week.
* @param workWeekDays - The allowed days in work week. If not provided, assumes all days are allowed.
* @param daysToSelectInDayView - The number of days to include when using dateRangeType === DateRangeType.Day
* for multiday view. Defaults to 1
* @returns An array of dates representing the date range containing the specified date.
*/
export declare function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firstDayOfWeek: DayOfWeek, workWeekDays?: DayOfWeek[], daysToSelectInDayView?: number): Date[];
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
export declare const getDateRangeTypeToUse: (dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined, firstDayOfWeek: DayOfWeek) => DateRangeType;
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
export declare const getDayGrid: (options: IDayGridOptions) => IDay[][];
/**
* Gets the date for the last day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
export declare function getEndDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
/**
* Returns a date that is the last day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the month.
*/
export declare function getMonthEnd(date: Date): Date;
/**
* Returns a date that is the first day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the month.
*/
export declare function getMonthStart(date: Date): Date;
/**
* Gets the date for the first day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
export declare function getStartDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param date - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The week's number in the year.
*/
export declare function getWeekNumber(date: Date, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear): number;
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param navigatedDate - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The weeks number array for the current month.
*/
export declare function getWeekNumbersInMonth(weeksInMonth: number, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear, navigatedDate: Date): number[];
/**
* Returns a date that is the last day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the year.
*/
export declare function getYearEnd(date: Date): Date;
/**
* Returns a date that is the first day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the year.
*/
export declare function getYearStart(date: Date): Date;
export declare interface IAvailableDateOptions extends IRestrictedDatesOptions {
/** Date from which we start the search */
initialDate: Date;
/** Ideal available date */
targetDate: Date;
/** Direction of search (`1` - search in future / `-1` search in past) */
direction: number;
}
/**
* {@docCategory DateTimeUtilities}
*/
export declare interface ICalendarStrings extends IDateGridStrings {
/**
* String to render for button to direct the user to today's date.
*/
goToToday: string;
/**
* Aria-label for the "previous month" button in day picker.
*/
prevMonthAriaLabel?: string;
/**
* Aria-label for the "next month" button in day picker.
*/
nextMonthAriaLabel?: string;
/**
* Aria-label for the "previous year" button in month picker.
*/
prevYearAriaLabel?: string;
/**
* Aria-label for the "next year" button in month picker.
*/
nextYearAriaLabel?: string;
/**
* Aria-label for the "previous year range" button in year picker.
*/
prevYearRangeAriaLabel?: string;
/**
* Aria-label for the "next year range" button in year picker.
*/
nextYearRangeAriaLabel?: string;
/**
* Aria-label format string for the header button in the month picker. Should have 1 string param, e.g. "`{0}`,
* select to change the year". This aria-label will only be applied if the year picker is enabled; otherwise
* the label will default to the header string, e.g. "2019".
*/
monthPickerHeaderAriaLabel?: string;
/**
* Aria-label format string for the header button in the year picker.
* Should have 1 string param, e.g. "`{0}`, select to change the month"
*/
yearPickerHeaderAriaLabel?: string;
/**
* Aria-label for the "close" button.
*/
closeButtonAriaLabel?: string;
/**
* Aria-label format string for the week number header. Should have 1 string param, e.g. "week number `{0}`"
*/
weekNumberFormatString?: string;
/**
* Aria-label format string for the currently selected date. Should have 1 string param, e.g. "Selected date `{0}`"
*/
selectedDateFormatString?: string;
/**
* Aria-label format string for today's date. Should have 1 string param, e.g. "Today's date `{0}`"
*/
todayDateFormatString?: string;
/**
* Aria-label for when a date is marked
*/
dayMarkedAriaLabel?: string;
}
/**
* {@docCategory DateTimeUtilities}
*/
export declare interface IDateFormatting {
/**
* Get a localized string for a day.
*/
formatDay: (date: Date) => string;
/**
* Get a localized string for a month.
*/
formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a year.
*/
formatYear: (date: Date) => string;
/**
* Get a localized string for a month, day, and year.
*/
formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a month and year.
*/
formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
}
/**
* {@docCategory DateTimeUtilities}
*/
export declare interface IDateGridStrings {
/**
* An array of strings for the full names of months.
* The array is 0-based, so months[0] should be the full name of January.
*/
months: string[];
/**
* An array of strings for the short names of months.
* The array is 0-based, so shortMonths[0] should be the short name of January.
*/
shortMonths: string[];
/**
* An array of strings for the full names of days of the week.
* The array is 0-based, so days[0] should be the full name of Sunday.
*/
days: string[];
/**
* An array of strings for the initials of the days of the week.
* The array is 0-based, so days[0] should be the initial of Sunday.
*/
shortDays: string[];
}
export declare interface IDay {
/** `Date.toString()` value of current date */
key: string;
/** `Date.getDate()` value of current date */
date: string;
/** `Date` object of current date */
originalDate: Date;
/** Is current date is in the same month as "today" date */
isInMonth: boolean;
/** Is current date is "today" date */
isToday: boolean;
/** Is current date is selected */
isSelected: boolean;
/** Is current date within restriction boundaries */
isInBounds: boolean;
/** Is current date marked */
isMarked: boolean;
}
/**
* {@docCategory DateTimeUtilities}
*/
export declare interface IDayGridOptions extends IRestrictedDatesOptions {
/**
* The first day of the week for your locale.
*/
firstDayOfWeek: DayOfWeek;
/**
* Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,
* FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
*/
firstWeekOfYear: FirstWeekOfYear;
/**
* The date range type indicating how many days should be selected as the user
* selects days
*/
dateRangeType: DateRangeType;
/**
* The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day
* views.
*/
daysToSelectInDayView?: number;
/**
* Value of today. If unspecified, current time in client machine will be used.
*/
today?: Date;
/**
* Whether the calendar should show the week number (weeks 1 to 53) before each week row
*/
showWeekNumbers?: boolean;
/**
* The days that are selectable when `dateRangeType` is WorkWeek.
* If `dateRangeType` is not WorkWeek this property does nothing.
*/
workWeekDays?: DayOfWeek[];
/**
* Which days in the generated grid should be marked.
*/
markedDays?: Date[];
/**
* The currently selected date
*/
selectedDate: Date;
/**
* The currently navigated date
*/
navigatedDate: Date;
/**
* How many weeks to show by default. If not provided, will show enough weeks to display the current
* month, between 4 and 6 depending
*/
weeksToShow?: number;
}
/**
* {@docCategory DateTimeUtilities}
*/
export declare interface IRestrictedDatesOptions {
/**
* If set the Calendar will not allow navigation to or selection of a date earlier than this value.
*/
minDate?: Date;
/**
* If set the Calendar will not allow navigation to or selection of a date later than this value.
*/
maxDate?: Date;
/**
* If set the Calendar will not allow selection of dates in this array.
*/
restrictedDates?: Date[];
}
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
export declare const isAfterMaxDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
export declare const isBeforeMinDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
/**
* Returns whether provided week days are contiguous.
* @param days - list of days in a week
* @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not
* @param firstDayOfWeek - decides which day of week is the first one in the order.
*/
export declare const isContiguous: (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek) => boolean;
/**
* Checks whether the specified date is in the given date range.
* @param date - The origin date
* @param dateRange - An array of dates to do the lookup on
* @returns True if the date matches one of the dates in the specified array, false otherwise.
*/
export declare function isInDateRangeArray(date: Date, dateRange: Date[]): boolean;
/**
* Checks if `date` falls into the restricted `options`
* @param date - date to check
* @param options - restriction options (min date, max date and list of restricted dates)
*/
export declare const isRestrictedDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
/**
* The months
* {@docCategory DateTimeUtilities}
*/
export declare enum MonthOfYear {
January = 0,
February = 1,
March = 2,
April = 3,
May = 4,
June = 5,
July = 6,
August = 7,
September = 8,
October = 9,
November = 10,
December = 11
}
/**
* Returns a date that is a copy of the given date, aside from the month changing to the given month.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param month - The 0-based index of the month to set on the date.
* @returns A new Date object with the given month set.
*/
export declare function setMonth(date: Date, month: number): Date;
export declare const TimeConstants: {
MillisecondsInOneDay: number;
MillisecondsIn1Sec: number;
MillisecondsIn1Min: number;
MillisecondsIn30Mins: number;
MillisecondsIn1Hour: number;
MinutesInOneDay: number;
MinutesInOneHour: number;
DaysInOneWeek: number;
MonthInOneYear: number;
HoursInOneDay: number;
SecondsInOneMinute: number;
OffsetTo24HourFormat: number;
/**
* Matches a time string. Groups:
* 1. hours (with or without leading 0)
* 2. minutes
* 3. seconds (optional)
* 4. meridiem (am/pm, case-insensitive, optional)
*/
TimeFormatRegex: RegExp;
};
export { }
@@ -0,0 +1,287 @@
## API Report File for "@fluentui/date-time-utilities"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
// @public
export function addDays(date: Date, days: number): Date;
// @public
export const addMinutes: (date: Date, minutes: number) => Date;
// @public
export function addMonths(date: Date, months: number): Date;
// @public
export function addWeeks(date: Date, weeks: number): Date;
// @public
export function addYears(date: Date, years: number): Date;
// @public
export const ceilMinuteToIncrement: (date: Date, increments: number) => Date;
// @public
export function compareDatePart(date1: Date, date2: Date): number;
// @public
export function compareDates(date1: Date, date2: Date): boolean;
// @public
export enum DateRangeType {
// (undocumented)
Day = 0,
// (undocumented)
Month = 2,
// (undocumented)
Week = 1,
// (undocumented)
WorkWeek = 3
}
// @public
export enum DayOfWeek {
// (undocumented)
Friday = 5,
// (undocumented)
Monday = 1,
// (undocumented)
Saturday = 6,
// (undocumented)
Sunday = 0,
// (undocumented)
Thursday = 4,
// (undocumented)
Tuesday = 2,
// (undocumented)
Wednesday = 3
}
// @public (undocumented)
export const DAYS_IN_WEEK = 7;
// @public (undocumented)
export const DEFAULT_CALENDAR_STRINGS: ICalendarStrings;
// @public (undocumented)
export const DEFAULT_DATE_FORMATTING: IDateFormatting;
// @public (undocumented)
export const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings;
// @public
export const findAvailableDate: (options: IAvailableDateOptions) => Date | undefined;
// @public
export enum FirstWeekOfYear {
// (undocumented)
FirstDay = 0,
// (undocumented)
FirstFourDayWeek = 2,
// (undocumented)
FirstFullWeek = 1
}
// @public
export const formatDay: (date: Date) => string;
// @public
export const formatMonth: (date: Date, strings: IDateGridStrings) => string;
// @public
export const formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
// @public
export const formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
// @public
export const formatTimeString: (date: Date, showSeconds?: boolean, useHour12?: boolean) => string;
// @public
export const formatYear: (date: Date) => string;
// @public
export const getBoundedDateRange: (dateRange: Date[], minDate?: Date, maxDate?: Date) => Date[];
// @public
export const getDateFromTimeSelection: (useHour12: boolean, dateStartAnchor: Date, selectedTime: string) => Date;
// @public
export function getDatePartHashValue(date: Date): number;
// @public
export function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firstDayOfWeek: DayOfWeek, workWeekDays?: DayOfWeek[], daysToSelectInDayView?: number): Date[];
// @public
export const getDateRangeTypeToUse: (dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined, firstDayOfWeek: DayOfWeek) => DateRangeType;
// @public
export const getDayGrid: (options: IDayGridOptions) => IDay[][];
// @public
export function getEndDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
// @public
export function getMonthEnd(date: Date): Date;
// @public
export function getMonthStart(date: Date): Date;
// @public
export function getStartDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
// @public
export function getWeekNumber(date: Date, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear): number;
// @public
export function getWeekNumbersInMonth(weeksInMonth: number, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear, navigatedDate: Date): number[];
// @public
export function getYearEnd(date: Date): Date;
// @public
export function getYearStart(date: Date): Date;
// @public (undocumented)
export interface IAvailableDateOptions extends IRestrictedDatesOptions {
direction: number;
initialDate: Date;
targetDate: Date;
}
// @public (undocumented)
export interface ICalendarStrings extends IDateGridStrings {
closeButtonAriaLabel?: string;
dayMarkedAriaLabel?: string;
goToToday: string;
monthPickerHeaderAriaLabel?: string;
nextMonthAriaLabel?: string;
nextYearAriaLabel?: string;
nextYearRangeAriaLabel?: string;
prevMonthAriaLabel?: string;
prevYearAriaLabel?: string;
prevYearRangeAriaLabel?: string;
selectedDateFormatString?: string;
todayDateFormatString?: string;
weekNumberFormatString?: string;
yearPickerHeaderAriaLabel?: string;
}
// @public (undocumented)
export interface IDateFormatting {
formatDay: (date: Date) => string;
formatMonth: (date: Date, strings: IDateGridStrings) => string;
formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
formatYear: (date: Date) => string;
}
// @public (undocumented)
export interface IDateGridStrings {
days: string[];
months: string[];
shortDays: string[];
shortMonths: string[];
}
// @public (undocumented)
export interface IDay {
date: string;
isInBounds: boolean;
isInMonth: boolean;
isMarked: boolean;
isSelected: boolean;
isToday: boolean;
key: string;
originalDate: Date;
}
// @public (undocumented)
export interface IDayGridOptions extends IRestrictedDatesOptions {
dateRangeType: DateRangeType;
daysToSelectInDayView?: number;
firstDayOfWeek: DayOfWeek;
firstWeekOfYear: FirstWeekOfYear;
markedDays?: Date[];
navigatedDate: Date;
selectedDate: Date;
showWeekNumbers?: boolean;
today?: Date;
weeksToShow?: number;
workWeekDays?: DayOfWeek[];
}
// @public (undocumented)
export interface IRestrictedDatesOptions {
maxDate?: Date;
minDate?: Date;
restrictedDates?: Date[];
}
// @public
export const isAfterMaxDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
// @public
export const isBeforeMinDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
// @public
export const isContiguous: (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek) => boolean;
// @public
export function isInDateRangeArray(date: Date, dateRange: Date[]): boolean;
// @public
export const isRestrictedDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
// @public
export enum MonthOfYear {
// (undocumented)
April = 3,
// (undocumented)
August = 7,
// (undocumented)
December = 11,
// (undocumented)
February = 1,
// (undocumented)
January = 0,
// (undocumented)
July = 6,
// (undocumented)
June = 5,
// (undocumented)
March = 2,
// (undocumented)
May = 4,
// (undocumented)
November = 10,
// (undocumented)
October = 9,
// (undocumented)
September = 8
}
// @public
export function setMonth(date: Date, month: number): Date;
// @public (undocumented)
export const TimeConstants: {
MillisecondsInOneDay: number;
MillisecondsIn1Sec: number;
MillisecondsIn1Min: number;
MillisecondsIn30Mins: number;
MillisecondsIn1Hour: number;
MinutesInOneDay: number;
MinutesInOneHour: number;
DaysInOneWeek: number;
MonthInOneYear: number;
HoursInOneDay: number;
SecondsInOneMinute: number;
OffsetTo24HourFormat: number;
TimeFormatRegex: RegExp;
};
// (No @packageDocumentation comment for this package)
```
+3
View File
@@ -0,0 +1,3 @@
import { preset } from '@fluentui/scripts-tasks';
preset();
@@ -0,0 +1,32 @@
import { IDateGridStrings, IDateFormatting, ICalendarStrings } from './dateFormatting.types';
/**
* Format date to a day string representation
* @param date - input date to format
*/
export declare const formatDay: (date: Date) => string;
/**
* Format date to a month-day-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a year string representation
* @param date - input date to format
*/
export declare const formatYear: (date: Date) => string;
export declare const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings;
export declare const DEFAULT_DATE_FORMATTING: IDateFormatting;
export declare const DEFAULT_CALENDAR_STRINGS: ICalendarStrings;
@@ -0,0 +1,70 @@
define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CALENDAR_STRINGS = exports.DEFAULT_DATE_FORMATTING = exports.DEFAULT_DATE_GRID_STRINGS = exports.formatYear = exports.formatMonth = exports.formatMonthYear = exports.formatMonthDayYear = exports.formatDay = void 0;
/**
* Format date to a day string representation
* @param date - input date to format
*/
var formatDay = function (date) { return date.getDate().toString(); };
exports.formatDay = formatDay;
/**
* Format date to a month-day-year string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonthDayYear = function (date, strings) {
return strings.months[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();
};
exports.formatMonthDayYear = formatMonthDayYear;
/**
* Format date to a month-year string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonthYear = function (date, strings) {
return strings.months[date.getMonth()] + ' ' + date.getFullYear();
};
exports.formatMonthYear = formatMonthYear;
/**
* Format date to a month string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonth = function (date, strings) { return strings.months[date.getMonth()]; };
exports.formatMonth = formatMonth;
/**
* Format date to a year string representation
* @param date - input date to format
*/
var formatYear = function (date) { return date.getFullYear().toString(); };
exports.formatYear = formatYear;
exports.DEFAULT_DATE_GRID_STRINGS = {
months: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
shortDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
};
exports.DEFAULT_DATE_FORMATTING = {
formatDay: exports.formatDay,
formatMonth: exports.formatMonth,
formatYear: exports.formatYear,
formatMonthDayYear: exports.formatMonthDayYear,
formatMonthYear: exports.formatMonthYear,
};
exports.DEFAULT_CALENDAR_STRINGS = tslib_1.__assign(tslib_1.__assign({}, exports.DEFAULT_DATE_GRID_STRINGS), { goToToday: 'Go to today', weekNumberFormatString: 'Week number {0}', prevMonthAriaLabel: 'Previous month', nextMonthAriaLabel: 'Next month', prevYearAriaLabel: 'Previous year', nextYearAriaLabel: 'Next year', prevYearRangeAriaLabel: 'Previous year range', nextYearRangeAriaLabel: 'Next year range', closeButtonAriaLabel: 'Close', selectedDateFormatString: 'Selected date {0}', todayDateFormatString: "Today's date {0}", monthPickerHeaderAriaLabel: '{0}, change year', yearPickerHeaderAriaLabel: '{0}, change month', dayMarkedAriaLabel: 'marked' });
});
//# sourceMappingURL=dateFormatting.defaults.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateFormatting.defaults.js","sourceRoot":"../src/","sources":["dateFormatting/dateFormatting.defaults.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACI,IAAM,SAAS,GAAG,UAAC,IAAU,IAAa,OAAA,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAzB,CAAyB,CAAC;IAA9D,QAAA,SAAS,aAAqD;IAE3E;;;;OAIG;IACI,IAAM,kBAAkB,GAAG,UAAC,IAAU,EAAE,OAAyB;QACtE,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE;IAAlF,CAAkF,CAAC;IADxE,QAAA,kBAAkB,sBACsD;IAErF;;;;OAIG;IACI,IAAM,eAAe,GAAG,UAAC,IAAU,EAAE,OAAyB;QACnE,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE;IAA1D,CAA0D,CAAC;IADhD,QAAA,eAAe,mBACiC;IAE7D;;;;OAIG;IACI,IAAM,WAAW,GAAG,UAAC,IAAU,EAAE,OAAyB,IAAa,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAA/B,CAA+B,CAAC;IAAjG,QAAA,WAAW,eAAsF;IAE9G;;;OAGG;IACI,IAAM,UAAU,GAAG,UAAC,IAAU,IAAa,OAAA,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,EAA7B,CAA6B,CAAC;IAAnE,QAAA,UAAU,cAAyD;IAEnE,QAAA,yBAAyB,GAAqB;QACzD,MAAM,EAAE;YACN,SAAS;YACT,UAAU;YACV,OAAO;YACP,OAAO;YACP,KAAK;YACL,MAAM;YACN,MAAM;YACN,QAAQ;YACR,WAAW;YACX,SAAS;YACT,UAAU;YACV,UAAU;SACX;QACD,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;QACjG,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC;QACpF,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;KAC/C,CAAC;IAEW,QAAA,uBAAuB,GAAoB;QACtD,SAAS,mBAAA;QACT,WAAW,qBAAA;QACX,UAAU,oBAAA;QACV,kBAAkB,4BAAA;QAClB,eAAe,yBAAA;KAChB,CAAC;IAEW,QAAA,wBAAwB,yCAChC,iCAAyB,KAE5B,SAAS,EAAE,aAAa,EACxB,sBAAsB,EAAE,iBAAiB,EACzC,kBAAkB,EAAE,gBAAgB,EACpC,kBAAkB,EAAE,YAAY,EAChC,iBAAiB,EAAE,eAAe,EAClC,iBAAiB,EAAE,WAAW,EAC9B,sBAAsB,EAAE,qBAAqB,EAC7C,sBAAsB,EAAE,iBAAiB,EACzC,oBAAoB,EAAE,OAAO,EAC7B,wBAAwB,EAAE,mBAAmB,EAC7C,qBAAqB,EAAE,kBAAkB,EACzC,0BAA0B,EAAE,kBAAkB,EAC9C,yBAAyB,EAAE,mBAAmB,EAC9C,kBAAkB,EAAE,QAAQ,IAC5B","sourcesContent":["import { IDateGridStrings, IDateFormatting, ICalendarStrings } from './dateFormatting.types';\n\n/**\n * Format date to a day string representation\n * @param date - input date to format\n */\nexport const formatDay = (date: Date): string => date.getDate().toString();\n\n/**\n * Format date to a month-day-year string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonthDayYear = (date: Date, strings: IDateGridStrings): string =>\n strings.months[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();\n\n/**\n * Format date to a month-year string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonthYear = (date: Date, strings: IDateGridStrings): string =>\n strings.months[date.getMonth()] + ' ' + date.getFullYear();\n\n/**\n * Format date to a month string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonth = (date: Date, strings: IDateGridStrings): string => strings.months[date.getMonth()];\n\n/**\n * Format date to a year string representation\n * @param date - input date to format\n */\nexport const formatYear = (date: Date): string => date.getFullYear().toString();\n\nexport const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings = {\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n shortDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n};\n\nexport const DEFAULT_DATE_FORMATTING: IDateFormatting = {\n formatDay,\n formatMonth,\n formatYear,\n formatMonthDayYear,\n formatMonthYear,\n};\n\nexport const DEFAULT_CALENDAR_STRINGS: ICalendarStrings = {\n ...DEFAULT_DATE_GRID_STRINGS,\n\n goToToday: 'Go to today',\n weekNumberFormatString: 'Week number {0}',\n prevMonthAriaLabel: 'Previous month',\n nextMonthAriaLabel: 'Next month',\n prevYearAriaLabel: 'Previous year',\n nextYearAriaLabel: 'Next year',\n prevYearRangeAriaLabel: 'Previous year range',\n nextYearRangeAriaLabel: 'Next year range',\n closeButtonAriaLabel: 'Close',\n selectedDateFormatString: 'Selected date {0}',\n todayDateFormatString: \"Today's date {0}\",\n monthPickerHeaderAriaLabel: '{0}, change year',\n yearPickerHeaderAriaLabel: '{0}, change month',\n dayMarkedAriaLabel: 'marked',\n};\n"]}
@@ -0,0 +1,114 @@
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDateGridStrings {
/**
* An array of strings for the full names of months.
* The array is 0-based, so months[0] should be the full name of January.
*/
months: string[];
/**
* An array of strings for the short names of months.
* The array is 0-based, so shortMonths[0] should be the short name of January.
*/
shortMonths: string[];
/**
* An array of strings for the full names of days of the week.
* The array is 0-based, so days[0] should be the full name of Sunday.
*/
days: string[];
/**
* An array of strings for the initials of the days of the week.
* The array is 0-based, so days[0] should be the initial of Sunday.
*/
shortDays: string[];
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDateFormatting {
/**
* Get a localized string for a day.
*/
formatDay: (date: Date) => string;
/**
* Get a localized string for a month.
*/
formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a year.
*/
formatYear: (date: Date) => string;
/**
* Get a localized string for a month, day, and year.
*/
formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a month and year.
*/
formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface ICalendarStrings extends IDateGridStrings {
/**
* String to render for button to direct the user to today's date.
*/
goToToday: string;
/**
* Aria-label for the "previous month" button in day picker.
*/
prevMonthAriaLabel?: string;
/**
* Aria-label for the "next month" button in day picker.
*/
nextMonthAriaLabel?: string;
/**
* Aria-label for the "previous year" button in month picker.
*/
prevYearAriaLabel?: string;
/**
* Aria-label for the "next year" button in month picker.
*/
nextYearAriaLabel?: string;
/**
* Aria-label for the "previous year range" button in year picker.
*/
prevYearRangeAriaLabel?: string;
/**
* Aria-label for the "next year range" button in year picker.
*/
nextYearRangeAriaLabel?: string;
/**
* Aria-label format string for the header button in the month picker. Should have 1 string param, e.g. "`{0}`,
* select to change the year". This aria-label will only be applied if the year picker is enabled; otherwise
* the label will default to the header string, e.g. "2019".
*/
monthPickerHeaderAriaLabel?: string;
/**
* Aria-label format string for the header button in the year picker.
* Should have 1 string param, e.g. "`{0}`, select to change the month"
*/
yearPickerHeaderAriaLabel?: string;
/**
* Aria-label for the "close" button.
*/
closeButtonAriaLabel?: string;
/**
* Aria-label format string for the week number header. Should have 1 string param, e.g. "week number `{0}`"
*/
weekNumberFormatString?: string;
/**
* Aria-label format string for the currently selected date. Should have 1 string param, e.g. "Selected date `{0}`"
*/
selectedDateFormatString?: string;
/**
* Aria-label format string for today's date. Should have 1 string param, e.g. "Today's date `{0}`"
*/
todayDateFormatString?: string;
/**
* Aria-label for when a date is marked
*/
dayMarkedAriaLabel?: string;
}
@@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
//# sourceMappingURL=dateFormatting.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateFormatting.types.js","sourceRoot":"../src/","sources":["dateFormatting/dateFormatting.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDateGridStrings {\n /**\n * An array of strings for the full names of months.\n * The array is 0-based, so months[0] should be the full name of January.\n */\n months: string[];\n\n /**\n * An array of strings for the short names of months.\n * The array is 0-based, so shortMonths[0] should be the short name of January.\n */\n shortMonths: string[];\n\n /**\n * An array of strings for the full names of days of the week.\n * The array is 0-based, so days[0] should be the full name of Sunday.\n */\n days: string[];\n\n /**\n * An array of strings for the initials of the days of the week.\n * The array is 0-based, so days[0] should be the initial of Sunday.\n */\n shortDays: string[];\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDateFormatting {\n /**\n * Get a localized string for a day.\n */\n formatDay: (date: Date) => string;\n\n /**\n * Get a localized string for a month.\n */\n formatMonth: (date: Date, strings: IDateGridStrings) => string;\n\n /**\n * Get a localized string for a year.\n */\n formatYear: (date: Date) => string;\n\n /**\n * Get a localized string for a month, day, and year.\n */\n formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;\n\n /**\n * Get a localized string for a month and year.\n */\n formatMonthYear: (date: Date, strings: IDateGridStrings) => string;\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface ICalendarStrings extends IDateGridStrings {\n /**\n * String to render for button to direct the user to today's date.\n */\n goToToday: string;\n\n /**\n * Aria-label for the \"previous month\" button in day picker.\n */\n prevMonthAriaLabel?: string;\n\n /**\n * Aria-label for the \"next month\" button in day picker.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Aria-label for the \"previous year\" button in month picker.\n */\n prevYearAriaLabel?: string;\n\n /**\n * Aria-label for the \"next year\" button in month picker.\n */\n nextYearAriaLabel?: string;\n\n /**\n * Aria-label for the \"previous year range\" button in year picker.\n */\n prevYearRangeAriaLabel?: string;\n\n /**\n * Aria-label for the \"next year range\" button in year picker.\n */\n nextYearRangeAriaLabel?: string;\n\n /**\n * Aria-label format string for the header button in the month picker. Should have 1 string param, e.g. \"`{0}`,\n * select to change the year\". This aria-label will only be applied if the year picker is enabled; otherwise\n * the label will default to the header string, e.g. \"2019\".\n */\n monthPickerHeaderAriaLabel?: string;\n\n /**\n * Aria-label format string for the header button in the year picker.\n * Should have 1 string param, e.g. \"`{0}`, select to change the month\"\n */\n yearPickerHeaderAriaLabel?: string;\n\n /**\n * Aria-label for the \"close\" button.\n */\n closeButtonAriaLabel?: string;\n\n /**\n * Aria-label format string for the week number header. Should have 1 string param, e.g. \"week number `{0}`\"\n */\n weekNumberFormatString?: string;\n\n /**\n * Aria-label format string for the currently selected date. Should have 1 string param, e.g. \"Selected date `{0}`\"\n */\n selectedDateFormatString?: string;\n\n /**\n * Aria-label format string for today's date. Should have 1 string param, e.g. \"Today's date `{0}`\"\n */\n todayDateFormatString?: string;\n\n /**\n * Aria-label for when a date is marked\n */\n dayMarkedAriaLabel?: string;\n}\n"]}
@@ -0,0 +1,2 @@
export * from './dateFormatting.types';
export * from './dateFormatting.defaults';
@@ -0,0 +1,7 @@
define(["require", "exports", "tslib", "./dateFormatting.types", "./dateFormatting.defaults"], function (require, exports, tslib_1, dateFormatting_types_1, dateFormatting_defaults_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
tslib_1.__exportStar(dateFormatting_types_1, exports);
tslib_1.__exportStar(dateFormatting_defaults_1, exports);
});
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateFormatting/index.ts"],"names":[],"mappings":";;;IAAA,sDAAuC;IACvC,yDAA0C","sourcesContent":["export * from './dateFormatting.types';\nexport * from './dateFormatting.defaults';\n"]}
@@ -0,0 +1,98 @@
import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';
export interface IDay {
/** `Date.toString()` value of current date */
key: string;
/** `Date.getDate()` value of current date */
date: string;
/** `Date` object of current date */
originalDate: Date;
/** Is current date is in the same month as "today" date */
isInMonth: boolean;
/** Is current date is "today" date */
isToday: boolean;
/** Is current date is selected */
isSelected: boolean;
/** Is current date within restriction boundaries */
isInBounds: boolean;
/** Is current date marked */
isMarked: boolean;
}
export interface IAvailableDateOptions extends IRestrictedDatesOptions {
/** Date from which we start the search */
initialDate: Date;
/** Ideal available date */
targetDate: Date;
/** Direction of search (`1` - search in future / `-1` search in past) */
direction: number;
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IRestrictedDatesOptions {
/**
* If set the Calendar will not allow navigation to or selection of a date earlier than this value.
*/
minDate?: Date;
/**
* If set the Calendar will not allow navigation to or selection of a date later than this value.
*/
maxDate?: Date;
/**
* If set the Calendar will not allow selection of dates in this array.
*/
restrictedDates?: Date[];
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDayGridOptions extends IRestrictedDatesOptions {
/**
* The first day of the week for your locale.
*/
firstDayOfWeek: DayOfWeek;
/**
* Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,
* FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
*/
firstWeekOfYear: FirstWeekOfYear;
/**
* The date range type indicating how many days should be selected as the user
* selects days
*/
dateRangeType: DateRangeType;
/**
* The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day
* views.
*/
daysToSelectInDayView?: number;
/**
* Value of today. If unspecified, current time in client machine will be used.
*/
today?: Date;
/**
* Whether the calendar should show the week number (weeks 1 to 53) before each week row
*/
showWeekNumbers?: boolean;
/**
* The days that are selectable when `dateRangeType` is WorkWeek.
* If `dateRangeType` is not WorkWeek this property does nothing.
*/
workWeekDays?: DayOfWeek[];
/**
* Which days in the generated grid should be marked.
*/
markedDays?: Date[];
/**
* The currently selected date
*/
selectedDate: Date;
/**
* The currently navigated date
*/
navigatedDate: Date;
/**
* How many weeks to show by default. If not provided, will show enough weeks to display the current
* month, between 4 and 6 depending
*/
weeksToShow?: number;
}
@@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
//# sourceMappingURL=dateGrid.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateGrid.types.js","sourceRoot":"../src/","sources":["dateGrid/dateGrid.types.ts"],"names":[],"mappings":"","sourcesContent":["import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';\n\nexport interface IDay {\n /** `Date.toString()` value of current date */\n key: string;\n /** `Date.getDate()` value of current date */\n date: string;\n /** `Date` object of current date */\n originalDate: Date;\n /** Is current date is in the same month as \"today\" date */\n isInMonth: boolean;\n /** Is current date is \"today\" date */\n isToday: boolean;\n /** Is current date is selected */\n isSelected: boolean;\n /** Is current date within restriction boundaries */\n isInBounds: boolean;\n /** Is current date marked */\n isMarked: boolean;\n}\n\nexport interface IAvailableDateOptions extends IRestrictedDatesOptions {\n /** Date from which we start the search */\n initialDate: Date;\n /** Ideal available date */\n targetDate: Date;\n /** Direction of search (`1` - search in future / `-1` search in past) */\n direction: number;\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IRestrictedDatesOptions {\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDayGridOptions extends IRestrictedDatesOptions {\n /**\n * The first day of the week for your locale.\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n */\n showWeekNumbers?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Which days in the generated grid should be marked.\n */\n markedDays?: Date[];\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n */\n weeksToShow?: number;\n}\n"]}
@@ -0,0 +1,6 @@
import { IAvailableDateOptions } from './dateGrid.types';
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
export declare const findAvailableDate: (options: IAvailableDateOptions) => Date | undefined;
@@ -0,0 +1,29 @@
define(["require", "exports", "tslib", "./isRestrictedDate", "./isAfterMaxDate", "./isBeforeMinDate", "../dateMath/dateMath"], function (require, exports, tslib_1, isRestrictedDate_1, isAfterMaxDate_1, isBeforeMinDate_1, dateMath_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findAvailableDate = void 0;
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
var findAvailableDate = function (options) {
var targetDate = options.targetDate, initialDate = options.initialDate, direction = options.direction, restrictedDateOptions = tslib_1.__rest(options, ["targetDate", "initialDate", "direction"]);
var availableDate = targetDate;
// if the target date is available, return it immediately
if (!(0, isRestrictedDate_1.isRestrictedDate)(targetDate, restrictedDateOptions)) {
return targetDate;
}
while ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 &&
(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions) &&
!(0, isAfterMaxDate_1.isAfterMaxDate)(availableDate, restrictedDateOptions) &&
!(0, isBeforeMinDate_1.isBeforeMinDate)(availableDate, restrictedDateOptions)) {
availableDate = (0, dateMath_1.addDays)(availableDate, direction);
}
if ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 && !(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions)) {
return availableDate;
}
return undefined;
};
exports.findAvailableDate = findAvailableDate;
});
//# sourceMappingURL=findAvailableDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findAvailableDate.js","sourceRoot":"../src/","sources":["dateGrid/findAvailableDate.ts"],"names":[],"mappings":";;;;IASA;;;OAGG;IACI,IAAM,iBAAiB,GAAG,UAAC,OAA8B;QACtD,IAAA,UAAU,GAAuD,OAAO,WAA9D,EAAE,WAAW,GAA0C,OAAO,YAAjD,EAAE,SAAS,GAA+B,OAAO,UAAtC,EAAK,qBAAqB,kBAAK,OAAO,EAA1E,0CAAgE,CAAF,CAAa;QACjF,IAAI,aAAa,GAAG,UAAU,CAAC;QAC/B,yDAAyD;QACzD,IAAI,CAAC,IAAA,mCAAgB,EAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACzD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,OACE,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC;YACjD,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC;YACtD,CAAC,IAAA,+BAAc,EAAC,aAAa,EAAE,qBAAqB,CAAC;YACrD,CAAC,IAAA,iCAAe,EAAC,aAAa,EAAE,qBAAqB,CAAC,EACtD,CAAC;YACD,aAAa,GAAG,IAAA,kBAAO,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACjH,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAtBW,QAAA,iBAAiB,qBAsB5B","sourcesContent":["import { IAvailableDateOptions } from './dateGrid.types';\n\nimport { isRestrictedDate } from './isRestrictedDate';\n\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { compareDatePart, addDays } from '../dateMath/dateMath';\n\n/**\n * Returns closest available date given the restriction `options`, or undefined otherwise\n * @param options - list of search options\n */\nexport const findAvailableDate = (options: IAvailableDateOptions): Date | undefined => {\n const { targetDate, initialDate, direction, ...restrictedDateOptions } = options;\n let availableDate = targetDate;\n // if the target date is available, return it immediately\n if (!isRestrictedDate(targetDate, restrictedDateOptions)) {\n return targetDate;\n }\n\n while (\n compareDatePart(initialDate, availableDate) !== 0 &&\n isRestrictedDate(availableDate, restrictedDateOptions) &&\n !isAfterMaxDate(availableDate, restrictedDateOptions) &&\n !isBeforeMinDate(availableDate, restrictedDateOptions)\n ) {\n availableDate = addDays(availableDate, direction);\n }\n\n if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {\n return availableDate;\n }\n\n return undefined;\n};\n"]}
@@ -0,0 +1,7 @@
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
export declare const getBoundedDateRange: (dateRange: Date[], minDate?: Date, maxDate?: Date) => Date[];
@@ -0,0 +1,23 @@
define(["require", "exports", "tslib", "../dateMath/dateMath"], function (require, exports, tslib_1, dateMath_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBoundedDateRange = void 0;
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
var getBoundedDateRange = function (dateRange, minDate, maxDate) {
var boundedDateRange = tslib_1.__spreadArray([], dateRange, true);
if (minDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, minDate) >= 0; });
}
if (maxDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, maxDate) <= 0; });
}
return boundedDateRange;
};
exports.getBoundedDateRange = getBoundedDateRange;
});
//# sourceMappingURL=getBoundedDateRange.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getBoundedDateRange.js","sourceRoot":"../src/","sources":["dateGrid/getBoundedDateRange.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACI,IAAM,mBAAmB,GAAG,UAAC,SAAiB,EAAE,OAAc,EAAE,OAAc;QACnF,IAAI,gBAAgB,6BAAO,SAAS,OAAC,CAAC;QACtC,IAAI,OAAO,EAAE,CAAC;YACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;QAC1G,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC;IATW,QAAA,mBAAmB,uBAS9B","sourcesContent":["import { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Generates a list of dates, bounded by min and max dates\n * @param dateRange - input date range\n * @param minDate - min date to limit the range\n * @param maxDate - max date to limit the range\n */\nexport const getBoundedDateRange = (dateRange: Date[], minDate?: Date, maxDate?: Date): Date[] => {\n let boundedDateRange = [...dateRange];\n if (minDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, minDate as Date) >= 0);\n }\n if (maxDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, maxDate as Date) <= 0);\n }\n return boundedDateRange;\n};\n"]}
@@ -0,0 +1,9 @@
import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
export declare const getDateRangeTypeToUse: (dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined, firstDayOfWeek: DayOfWeek) => DateRangeType;
@@ -0,0 +1,22 @@
define(["require", "exports", "../dateValues/dateValues", "./isContiguous"], function (require, exports, dateValues_1, isContiguous_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateRangeTypeToUse = void 0;
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
var getDateRangeTypeToUse = function (dateRangeType, workWeekDays, firstDayOfWeek) {
if (workWeekDays && dateRangeType === dateValues_1.DateRangeType.WorkWeek) {
if (!(0, isContiguous_1.isContiguous)(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {
return dateValues_1.DateRangeType.Week;
}
}
return dateRangeType;
};
exports.getDateRangeTypeToUse = getDateRangeTypeToUse;
});
//# sourceMappingURL=getDateRangeTypeToUse.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getDateRangeTypeToUse.js","sourceRoot":"../src/","sources":["dateGrid/getDateRangeTypeToUse.ts"],"names":[],"mappings":";;;;IAEA;;;;;;OAMG;IACI,IAAM,qBAAqB,GAAG,UACnC,aAA4B,EAC5B,YAAqC,EACrC,cAAyB;QAEzB,IAAI,YAAY,IAAI,aAAa,KAAK,0BAAa,CAAC,QAAQ,EAAE,CAAC;YAC7D,IAAI,CAAC,IAAA,2BAAY,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnF,OAAO,0BAAa,CAAC,IAAI,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAZW,QAAA,qBAAqB,yBAYhC","sourcesContent":["import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';\nimport { isContiguous } from './isContiguous';\n/**\n * Return corrected date range type, given `dateRangeType` and list of working days.\n * For non-contiguous working days and working week range type, returns general week range type.\n * For other cases returns input date range type.\n * @param dateRangeType - input type of range\n * @param workWeekDays - list of working days in a week\n */\nexport const getDateRangeTypeToUse = (\n dateRangeType: DateRangeType,\n workWeekDays: DayOfWeek[] | undefined,\n firstDayOfWeek: DayOfWeek,\n): DateRangeType => {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n if (!isContiguous(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n};\n"]}
@@ -0,0 +1,8 @@
import { IDay, IDayGridOptions } from './dateGrid.types';
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
export declare const getDayGrid: (options: IDayGridOptions) => IDay[][];
@@ -0,0 +1,74 @@
define(["require", "exports", "../dateMath/dateMath", "../dateValues/dateValues", "./getDateRangeTypeToUse", "./getBoundedDateRange", "./isRestrictedDate"], function (require, exports, dateMath_1, dateValues_1, getDateRangeTypeToUse_1, getBoundedDateRange_1, isRestrictedDate_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDayGrid = void 0;
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
var getDayGrid = function (options) {
var selectedDate = options.selectedDate, dateRangeType = options.dateRangeType, firstDayOfWeek = options.firstDayOfWeek, today = options.today, minDate = options.minDate, maxDate = options.maxDate, weeksToShow = options.weeksToShow, workWeekDays = options.workWeekDays, daysToSelectInDayView = options.daysToSelectInDayView, restrictedDates = options.restrictedDates, markedDays = options.markedDays;
var restrictedDateOptions = { minDate: minDate, maxDate: maxDate, restrictedDates: restrictedDates };
var todaysDate = today || new Date();
var navigatedDate = options.navigatedDate ? options.navigatedDate : todaysDate;
var date;
if (weeksToShow && weeksToShow <= 4) {
// if showing less than a full month, just use date == navigatedDate
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), navigatedDate.getDate());
}
else {
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);
}
var weeks = [];
// Cycle the date backwards to get to the first day of the week.
while (date.getDay() !== firstDayOfWeek) {
date.setDate(date.getDate() - 1);
}
// add the transition week as last week of previous range
date = (0, dateMath_1.addDays)(date, -dateValues_1.DAYS_IN_WEEK);
// a flag to indicate whether all days of the week are outside the month
var isAllDaysOfWeekOutOfMonth = false;
// in work week view if the days aren't contiguous we use week view instead
var selectedDateRangeType = (0, getDateRangeTypeToUse_1.getDateRangeTypeToUse)(dateRangeType, workWeekDays, firstDayOfWeek);
var selectedDates = [];
if (selectedDate) {
selectedDates = (0, dateMath_1.getDateRangeArray)(selectedDate, selectedDateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);
selectedDates = (0, getBoundedDateRange_1.getBoundedDateRange)(selectedDates, minDate, maxDate);
}
var shouldGetWeeks = true;
for (var weekIndex = 0; shouldGetWeeks; weekIndex++) {
var week = [];
isAllDaysOfWeekOutOfMonth = true;
var _loop_1 = function (dayIndex) {
var originalDate = new Date(date.getTime());
var dayInfo = {
key: date.toString(),
date: date.getDate().toString(),
originalDate: originalDate,
isInMonth: date.getMonth() === navigatedDate.getMonth(),
isToday: (0, dateMath_1.compareDates)(todaysDate, date),
isSelected: (0, dateMath_1.isInDateRangeArray)(date, selectedDates),
isInBounds: !(0, isRestrictedDate_1.isRestrictedDate)(date, restrictedDateOptions),
isMarked: (markedDays === null || markedDays === void 0 ? void 0 : markedDays.some(function (markedDay) { return (0, dateMath_1.compareDates)(originalDate, markedDay); })) || false,
};
week.push(dayInfo);
if (dayInfo.isInMonth) {
isAllDaysOfWeekOutOfMonth = false;
}
date.setDate(date.getDate() + 1);
};
for (var dayIndex = 0; dayIndex < dateValues_1.DAYS_IN_WEEK; dayIndex++) {
_loop_1(dayIndex);
}
// We append the condition of the loop depending upon the showSixWeeksByDefault prop.
shouldGetWeeks = weeksToShow ? weekIndex < weeksToShow + 1 : !isAllDaysOfWeekOutOfMonth || weekIndex === 0;
// we don't check shouldGetWeeks before pushing because we want to add one extra week for transition state
weeks.push(week);
}
return weeks;
};
exports.getDayGrid = getDayGrid;
});
//# sourceMappingURL=getDayGrid.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
export * from './dateGrid.types';
export * from './findAvailableDate';
export * from './getBoundedDateRange';
export * from './getDateRangeTypeToUse';
export * from './getDayGrid';
export * from './isAfterMaxDate';
export * from './isBeforeMinDate';
export * from './isRestrictedDate';
export * from './isContiguous';
+14
View File
@@ -0,0 +1,14 @@
define(["require", "exports", "tslib", "./dateGrid.types", "./findAvailableDate", "./getBoundedDateRange", "./getDateRangeTypeToUse", "./getDayGrid", "./isAfterMaxDate", "./isBeforeMinDate", "./isRestrictedDate", "./isContiguous"], function (require, exports, tslib_1, dateGrid_types_1, findAvailableDate_1, getBoundedDateRange_1, getDateRangeTypeToUse_1, getDayGrid_1, isAfterMaxDate_1, isBeforeMinDate_1, isRestrictedDate_1, isContiguous_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
tslib_1.__exportStar(dateGrid_types_1, exports);
tslib_1.__exportStar(findAvailableDate_1, exports);
tslib_1.__exportStar(getBoundedDateRange_1, exports);
tslib_1.__exportStar(getDateRangeTypeToUse_1, exports);
tslib_1.__exportStar(getDayGrid_1, exports);
tslib_1.__exportStar(isAfterMaxDate_1, exports);
tslib_1.__exportStar(isBeforeMinDate_1, exports);
tslib_1.__exportStar(isRestrictedDate_1, exports);
tslib_1.__exportStar(isContiguous_1, exports);
});
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateGrid/index.ts"],"names":[],"mappings":";;;IAAA,gDAAiC;IACjC,mDAAoC;IACpC,qDAAsC;IACtC,uDAAwC;IACxC,4CAA6B;IAC7B,gDAAiC;IACjC,iDAAkC;IAClC,kDAAmC;IACnC,8CAA+B","sourcesContent":["export * from './dateGrid.types';\nexport * from './findAvailableDate';\nexport * from './getBoundedDateRange';\nexport * from './getDateRangeTypeToUse';\nexport * from './getDayGrid';\nexport * from './isAfterMaxDate';\nexport * from './isBeforeMinDate';\nexport * from './isRestrictedDate';\nexport * from './isContiguous';\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
export declare const isAfterMaxDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,16 @@
define(["require", "exports", "../dateMath/dateMath"], function (require, exports, dateMath_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAfterMaxDate = void 0;
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
var isAfterMaxDate = function (date, options) {
var maxDate = options.maxDate;
return maxDate ? (0, dateMath_1.compareDatePart)(date, maxDate) >= 1 : false;
};
exports.isAfterMaxDate = isAfterMaxDate;
});
//# sourceMappingURL=isAfterMaxDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isAfterMaxDate.js","sourceRoot":"../src/","sources":["dateGrid/isAfterMaxDate.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACI,IAAM,cAAc,GAAG,UAAC,IAAU,EAAE,OAAgC;QACjE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/D,CAAC,CAAC;IAHW,QAAA,cAAc,kBAGzB","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens later than max date\n * @param date - date to check\n * @param options - object with max date to check against\n */\nexport const isAfterMaxDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { maxDate } = options;\n return maxDate ? compareDatePart(date, maxDate) >= 1 : false;\n};\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
export declare const isBeforeMinDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,16 @@
define(["require", "exports", "../dateMath/dateMath"], function (require, exports, dateMath_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBeforeMinDate = void 0;
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
var isBeforeMinDate = function (date, options) {
var minDate = options.minDate;
return minDate ? (0, dateMath_1.compareDatePart)(minDate, date) >= 1 : false;
};
exports.isBeforeMinDate = isBeforeMinDate;
});
//# sourceMappingURL=isBeforeMinDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isBeforeMinDate.js","sourceRoot":"../src/","sources":["dateGrid/isBeforeMinDate.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACI,IAAM,eAAe,GAAG,UAAC,IAAU,EAAE,OAAgC;QAClE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/D,CAAC,CAAC;IAHW,QAAA,eAAe,mBAG1B","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens earlier than min date\n * @param date - date to check\n * @param options - object with min date to check against\n */\nexport const isBeforeMinDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { minDate } = options;\n return minDate ? compareDatePart(minDate, date) >= 1 : false;\n};\n"]}
@@ -0,0 +1,8 @@
import { DayOfWeek } from '../dateValues/dateValues';
/**
* Returns whether provided week days are contiguous.
* @param days - list of days in a week
* @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not
* @param firstDayOfWeek - decides which day of week is the first one in the order.
*/
export declare const isContiguous: (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek) => boolean;
@@ -0,0 +1,27 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isContiguous = void 0;
/**
* Returns whether provided week days are contiguous.
* @param days - list of days in a week
* @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not
* @param firstDayOfWeek - decides which day of week is the first one in the order.
*/
var isContiguous = function (days, isSingleWeek, firstDayOfWeek) {
var daySet = new Set(days);
var amountOfNoNeighbors = 0;
for (var _i = 0, days_1 = days; _i < days_1.length; _i++) {
var day = days_1[_i];
var nextDay = (day + 1) % 7;
if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {
amountOfNoNeighbors++;
}
}
// In case the full week is provided, then each day has a neighbor
//, otherwise the last day does not have a neighbor.
return amountOfNoNeighbors < 2;
};
exports.isContiguous = isContiguous;
});
//# sourceMappingURL=isContiguous.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isContiguous.js","sourceRoot":"../src/","sources":["dateGrid/isContiguous.ts"],"names":[],"mappings":";;;;IAEA;;;;;OAKG;IACI,IAAM,YAAY,GAAG,UAAC,IAAiB,EAAE,YAAqB,EAAE,cAAyB;QAC9F,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,mBAAmB,GAAG,CAAC,CAAC;QAC5B,KAAkB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE,CAAC;YAApB,IAAM,GAAG,aAAA;YACZ,IAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,cAAc,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;gBAC5E,mBAAmB,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;QAED,kEAAkE;QAClE,oDAAoD;QACpD,OAAO,mBAAmB,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC;IAbW,QAAA,YAAY,gBAavB","sourcesContent":["import { DayOfWeek } from '../dateValues/dateValues';\n\n/**\n * Returns whether provided week days are contiguous.\n * @param days - list of days in a week\n * @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not\n * @param firstDayOfWeek - decides which day of week is the first one in the order.\n */\nexport const isContiguous = (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek): boolean => {\n const daySet = new Set(days);\n let amountOfNoNeighbors = 0;\n for (const day of days) {\n const nextDay = (day + 1) % 7;\n if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {\n amountOfNoNeighbors++;\n }\n }\n\n // In case the full week is provided, then each day has a neighbor\n //, otherwise the last day does not have a neighbor.\n return amountOfNoNeighbors < 2;\n};\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` falls into the restricted `options`
* @param date - date to check
* @param options - restriction options (min date, max date and list of restricted dates)
*/
export declare const isRestrictedDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,20 @@
define(["require", "exports", "../dateMath/dateMath", "./isBeforeMinDate", "./isAfterMaxDate"], function (require, exports, dateMath_1, isBeforeMinDate_1, isAfterMaxDate_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRestrictedDate = void 0;
/**
* Checks if `date` falls into the restricted `options`
* @param date - date to check
* @param options - restriction options (min date, max date and list of restricted dates)
*/
var isRestrictedDate = function (date, options) {
var restrictedDates = options.restrictedDates, minDate = options.minDate, maxDate = options.maxDate;
if (!restrictedDates && !minDate && !maxDate) {
return false;
}
var inRestrictedDates = restrictedDates && restrictedDates.some(function (rd) { return (0, dateMath_1.compareDates)(rd, date); });
return inRestrictedDates || (0, isBeforeMinDate_1.isBeforeMinDate)(date, options) || (0, isAfterMaxDate_1.isAfterMaxDate)(date, options);
};
exports.isRestrictedDate = isRestrictedDate;
});
//# sourceMappingURL=isRestrictedDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isRestrictedDate.js","sourceRoot":"../src/","sources":["dateGrid/isRestrictedDate.ts"],"names":[],"mappings":";;;;IAKA;;;;OAIG;IACI,IAAM,gBAAgB,GAAG,UAAC,IAAU,EAAE,OAAgC;QACnE,IAAA,eAAe,GAAuB,OAAO,gBAA9B,EAAE,OAAO,GAAc,OAAO,QAArB,EAAE,OAAO,GAAK,OAAO,QAAZ,CAAa;QACtD,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAM,iBAAiB,GAAG,eAAe,IAAI,eAAe,CAAC,IAAI,CAAC,UAAC,EAAQ,IAAK,OAAA,IAAA,uBAAY,EAAC,EAAE,EAAE,IAAI,CAAC,EAAtB,CAAsB,CAAC,CAAC;QACxG,OAAO,iBAAiB,IAAI,IAAA,iCAAe,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAA,+BAAc,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9F,CAAC,CAAC;IAPW,QAAA,gBAAgB,oBAO3B","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDates } from '../dateMath/dateMath';\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\n/**\n * Checks if `date` falls into the restricted `options`\n * @param date - date to check\n * @param options - restriction options (min date, max date and list of restricted dates)\n */\nexport const isRestrictedDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { restrictedDates, minDate, maxDate } = options;\n if (!restrictedDates && !minDate && !maxDate) {\n return false;\n }\n const inRestrictedDates = restrictedDates && restrictedDates.some((rd: Date) => compareDates(rd, date));\n return inRestrictedDates || isBeforeMinDate(date, options) || isAfterMaxDate(date, options);\n};\n"]}
@@ -0,0 +1,134 @@
import { DayOfWeek, FirstWeekOfYear, DateRangeType } from '../dateValues/dateValues';
/**
* Returns a date offset from the given date by the specified number of days.
* @param date - The origin date
* @param days - The number of days to offset. 'days' can be negative.
* @returns A new Date object offset from the origin date by the given number of days
*/
export declare function addDays(date: Date, days: number): Date;
/**
* Returns a date offset from the given date by the specified number of weeks.
* @param date - The origin date
* @param weeks - The number of weeks to offset. 'weeks' can be negative.
* @returns A new Date object offset from the origin date by the given number of weeks
*/
export declare function addWeeks(date: Date, weeks: number): Date;
/**
* Returns a date offset from the given date by the specified number of months.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param months - The number of months to offset. 'months' can be negative.
* @returns A new Date object offset from the origin date by the given number of months
*/
export declare function addMonths(date: Date, months: number): Date;
/**
* Returns a date offset from the given date by the specified number of years.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param years - The number of years to offset. 'years' can be negative.
* @returns A new Date object offset from the origin date by the given number of years
*/
export declare function addYears(date: Date, years: number): Date;
/**
* Returns a date that is the first day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the month.
*/
export declare function getMonthStart(date: Date): Date;
/**
* Returns a date that is the last day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the month.
*/
export declare function getMonthEnd(date: Date): Date;
/**
* Returns a date that is the first day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the year.
*/
export declare function getYearStart(date: Date): Date;
/**
* Returns a date that is the last day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the year.
*/
export declare function getYearEnd(date: Date): Date;
/**
* Returns a date that is a copy of the given date, aside from the month changing to the given month.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param month - The 0-based index of the month to set on the date.
* @returns A new Date object with the given month set.
*/
export declare function setMonth(date: Date, month: number): Date;
/**
* Compares two dates, and returns true if the two dates (not accounting for time-of-day) are equal.
* @returns True if the two dates represent the same date (regardless of time-of-day), false otherwise.
*/
export declare function compareDates(date1: Date, date2: Date): boolean;
/**
* Compare the date parts of two dates
* @param date1 - The first date to compare
* @param date2 - The second date to compare
* @returns A negative value if date1 is earlier than date2, 0 if the dates are equal, or a positive value
* if date1 is later than date2.
*/
export declare function compareDatePart(date1: Date, date2: Date): number;
/**
* Gets the date range array including the specified date. The date range array is calculated as the list
* of dates accounting for the specified first day of the week and date range type.
* @param date - The input date
* @param dateRangeType - The desired date range type, i.e., day, week, month, etc.
* @param firstDayOfWeek - The first day of the week.
* @param workWeekDays - The allowed days in work week. If not provided, assumes all days are allowed.
* @param daysToSelectInDayView - The number of days to include when using dateRangeType === DateRangeType.Day
* for multiday view. Defaults to 1
* @returns An array of dates representing the date range containing the specified date.
*/
export declare function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firstDayOfWeek: DayOfWeek, workWeekDays?: DayOfWeek[], daysToSelectInDayView?: number): Date[];
/**
* Checks whether the specified date is in the given date range.
* @param date - The origin date
* @param dateRange - An array of dates to do the lookup on
* @returns True if the date matches one of the dates in the specified array, false otherwise.
*/
export declare function isInDateRangeArray(date: Date, dateRange: Date[]): boolean;
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param navigatedDate - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The weeks number array for the current month.
*/
export declare function getWeekNumbersInMonth(weeksInMonth: number, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear, navigatedDate: Date): number[];
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param date - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The week's number in the year.
*/
export declare function getWeekNumber(date: Date, firstDayOfWeek: DayOfWeek, firstWeekOfYear: FirstWeekOfYear): number;
/**
* Gets the date for the first day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
export declare function getStartDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
/**
* Gets the date for the last day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
export declare function getEndDateOfWeek(date: Date, firstDayOfWeek: DayOfWeek): Date;
/**
* Helper function to assist in date comparisons
*/
export declare function getDatePartHashValue(date: Date): number;
+392
View File
@@ -0,0 +1,392 @@
define(["require", "exports", "../dateValues/dateValues", "../dateValues/timeConstants"], function (require, exports, dateValues_1, timeConstants_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addDays = addDays;
exports.addWeeks = addWeeks;
exports.addMonths = addMonths;
exports.addYears = addYears;
exports.getMonthStart = getMonthStart;
exports.getMonthEnd = getMonthEnd;
exports.getYearStart = getYearStart;
exports.getYearEnd = getYearEnd;
exports.setMonth = setMonth;
exports.compareDates = compareDates;
exports.compareDatePart = compareDatePart;
exports.getDateRangeArray = getDateRangeArray;
exports.isInDateRangeArray = isInDateRangeArray;
exports.getWeekNumbersInMonth = getWeekNumbersInMonth;
exports.getWeekNumber = getWeekNumber;
exports.getStartDateOfWeek = getStartDateOfWeek;
exports.getEndDateOfWeek = getEndDateOfWeek;
exports.getDatePartHashValue = getDatePartHashValue;
/**
* Returns a date offset from the given date by the specified number of days.
* @param date - The origin date
* @param days - The number of days to offset. 'days' can be negative.
* @returns A new Date object offset from the origin date by the given number of days
*/
function addDays(date, days) {
var result = new Date(date.getTime());
result.setDate(result.getDate() + days);
return result;
}
/**
* Returns a date offset from the given date by the specified number of weeks.
* @param date - The origin date
* @param weeks - The number of weeks to offset. 'weeks' can be negative.
* @returns A new Date object offset from the origin date by the given number of weeks
*/
function addWeeks(date, weeks) {
return addDays(date, weeks * timeConstants_1.TimeConstants.DaysInOneWeek);
}
/**
* Returns a date offset from the given date by the specified number of months.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param months - The number of months to offset. 'months' can be negative.
* @returns A new Date object offset from the origin date by the given number of months
*/
function addMonths(date, months) {
var result = new Date(date.getTime());
var newMonth = result.getMonth() + months;
result.setMonth(newMonth);
// We want to maintain the same day-of-month, but that may not be possible if the new month doesn't have enough days.
// Loop until we back up to a day the new month has.
// (Weird modulo math is due to Javascript's treatment of negative numbers in modulo)
if (result.getMonth() !==
((newMonth % timeConstants_1.TimeConstants.MonthInOneYear) + timeConstants_1.TimeConstants.MonthInOneYear) % timeConstants_1.TimeConstants.MonthInOneYear) {
result = addDays(result, -result.getDate());
}
return result;
}
/**
* Returns a date offset from the given date by the specified number of years.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param years - The number of years to offset. 'years' can be negative.
* @returns A new Date object offset from the origin date by the given number of years
*/
function addYears(date, years) {
var result = new Date(date.getTime());
result.setFullYear(date.getFullYear() + years);
// We want to maintain the same day-of-month, but that may not be possible if the new month doesn't have enough days.
// Loop until we back up to a day the new month has.
// (Weird modulo math is due to Javascript's treatment of negative numbers in modulo)
if (result.getMonth() !==
((date.getMonth() % timeConstants_1.TimeConstants.MonthInOneYear) + timeConstants_1.TimeConstants.MonthInOneYear) % timeConstants_1.TimeConstants.MonthInOneYear) {
result = addDays(result, -result.getDate());
}
return result;
}
/**
* Returns a date that is the first day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the month.
*/
function getMonthStart(date) {
return new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0, 0);
}
/**
* Returns a date that is the last day of the month of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the month.
*/
function getMonthEnd(date) {
return new Date(date.getFullYear(), date.getMonth() + 1, 0, 0, 0, 0, 0);
}
/**
* Returns a date that is the first day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the first day of the year.
*/
function getYearStart(date) {
return new Date(date.getFullYear(), 0, 1, 0, 0, 0, 0);
}
/**
* Returns a date that is the last day of the year of the provided date.
* @param date - The origin date
* @returns A new Date object with the day set to the last day of the year.
*/
function getYearEnd(date) {
return new Date(date.getFullYear() + 1, 0, 0, 0, 0, 0, 0);
}
/**
* Returns a date that is a copy of the given date, aside from the month changing to the given month.
* The method tries to preserve the day-of-month; however, if the new month does not have enough days
* to contain the original day-of-month, we'll use the last day of the new month.
* @param date - The origin date
* @param month - The 0-based index of the month to set on the date.
* @returns A new Date object with the given month set.
*/
function setMonth(date, month) {
return addMonths(date, month - date.getMonth());
}
/**
* Compares two dates, and returns true if the two dates (not accounting for time-of-day) are equal.
* @returns True if the two dates represent the same date (regardless of time-of-day), false otherwise.
*/
function compareDates(date1, date2) {
if (!date1 && !date2) {
return true;
}
else if (!date1 || !date2) {
return false;
}
else {
return (date1.getFullYear() === date2.getFullYear() &&
date1.getMonth() === date2.getMonth() &&
date1.getDate() === date2.getDate());
}
}
/**
* Compare the date parts of two dates
* @param date1 - The first date to compare
* @param date2 - The second date to compare
* @returns A negative value if date1 is earlier than date2, 0 if the dates are equal, or a positive value
* if date1 is later than date2.
*/
function compareDatePart(date1, date2) {
return getDatePartHashValue(date1) - getDatePartHashValue(date2);
}
/**
* Gets the date range array including the specified date. The date range array is calculated as the list
* of dates accounting for the specified first day of the week and date range type.
* @param date - The input date
* @param dateRangeType - The desired date range type, i.e., day, week, month, etc.
* @param firstDayOfWeek - The first day of the week.
* @param workWeekDays - The allowed days in work week. If not provided, assumes all days are allowed.
* @param daysToSelectInDayView - The number of days to include when using dateRangeType === DateRangeType.Day
* for multiday view. Defaults to 1
* @returns An array of dates representing the date range containing the specified date.
*/
function getDateRangeArray(date, dateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView) {
if (daysToSelectInDayView === void 0) { daysToSelectInDayView = 1; }
var datesArray = [];
var startDate;
var endDate = null;
if (!workWeekDays) {
workWeekDays = [dateValues_1.DayOfWeek.Monday, dateValues_1.DayOfWeek.Tuesday, dateValues_1.DayOfWeek.Wednesday, dateValues_1.DayOfWeek.Thursday, dateValues_1.DayOfWeek.Friday];
}
daysToSelectInDayView = Math.max(daysToSelectInDayView, 1);
switch (dateRangeType) {
case dateValues_1.DateRangeType.Day:
startDate = getDatePart(date);
endDate = addDays(startDate, daysToSelectInDayView);
break;
case dateValues_1.DateRangeType.Week:
case dateValues_1.DateRangeType.WorkWeek:
startDate = getStartDateOfWeek(getDatePart(date), firstDayOfWeek);
endDate = addDays(startDate, timeConstants_1.TimeConstants.DaysInOneWeek);
break;
case dateValues_1.DateRangeType.Month:
startDate = new Date(date.getFullYear(), date.getMonth(), 1);
endDate = addMonths(startDate, 1);
break;
default:
throw new Error('Unexpected object: ' + dateRangeType);
}
// Populate the dates array with the dates in range
var nextDate = startDate;
do {
if (dateRangeType !== dateValues_1.DateRangeType.WorkWeek) {
// push all days not in work week view
datesArray.push(nextDate);
}
else if (workWeekDays.indexOf(nextDate.getDay()) !== -1) {
datesArray.push(nextDate);
}
nextDate = addDays(nextDate, 1);
} while (!compareDates(nextDate, endDate));
return datesArray;
}
/**
* Checks whether the specified date is in the given date range.
* @param date - The origin date
* @param dateRange - An array of dates to do the lookup on
* @returns True if the date matches one of the dates in the specified array, false otherwise.
*/
function isInDateRangeArray(date, dateRange) {
for (var _i = 0, dateRange_1 = dateRange; _i < dateRange_1.length; _i++) {
var dateInRange = dateRange_1[_i];
if (compareDates(date, dateInRange)) {
return true;
}
}
return false;
}
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param navigatedDate - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The weeks number array for the current month.
*/
function getWeekNumbersInMonth(weeksInMonth, firstDayOfWeek, firstWeekOfYear, navigatedDate) {
var selectedYear = navigatedDate.getFullYear();
var selectedMonth = navigatedDate.getMonth();
var dayOfMonth = 1;
var fistDayOfMonth = new Date(selectedYear, selectedMonth, dayOfMonth);
var endOfFirstWeek = dayOfMonth +
(firstDayOfWeek + timeConstants_1.TimeConstants.DaysInOneWeek - 1) -
adjustWeekDay(firstDayOfWeek, fistDayOfMonth.getDay());
var endOfWeekRange = new Date(selectedYear, selectedMonth, endOfFirstWeek);
dayOfMonth = endOfWeekRange.getDate();
var weeksArray = [];
for (var i = 0; i < weeksInMonth; i++) {
// Get week number for end of week
weeksArray.push(getWeekNumber(endOfWeekRange, firstDayOfWeek, firstWeekOfYear));
dayOfMonth += timeConstants_1.TimeConstants.DaysInOneWeek;
endOfWeekRange = new Date(selectedYear, selectedMonth, dayOfMonth);
}
return weeksArray;
}
/**
* Returns the week number for a date.
* Week numbers are 1 - 52 (53) in a year
* @param date - A date to find the week number for.
* @param firstDayOfWeek - The first day of the week (0-6, Sunday = 0)
* @param firstWeekOfYear - The first week of the year (1-2)
* @returns The week's number in the year.
*/
function getWeekNumber(date, firstDayOfWeek, firstWeekOfYear) {
// First four-day week of the year - minumum days count
var fourDayWeek = 4;
switch (firstWeekOfYear) {
case dateValues_1.FirstWeekOfYear.FirstFullWeek:
return getWeekOfYearFullDays(date, firstDayOfWeek, timeConstants_1.TimeConstants.DaysInOneWeek);
case dateValues_1.FirstWeekOfYear.FirstFourDayWeek:
return getWeekOfYearFullDays(date, firstDayOfWeek, fourDayWeek);
default:
return getFirstDayWeekOfYear(date, firstDayOfWeek);
}
}
/**
* Gets the date for the first day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
function getStartDateOfWeek(date, firstDayOfWeek) {
var daysOffset = firstDayOfWeek - date.getDay();
if (daysOffset > 0) {
// If first day of week is > date, go 1 week back, to ensure resulting date is in the past.
daysOffset -= timeConstants_1.TimeConstants.DaysInOneWeek;
}
return addDays(date, daysOffset);
}
/**
* Gets the date for the last day of the week based on the given date assuming
* the specified first day of the week.
* @param date - The date to find the beginning of the week date for.
* @returns A new date object representing the first day of the week containing the input date.
*/
function getEndDateOfWeek(date, firstDayOfWeek) {
var lastDayOfWeek = firstDayOfWeek - 1 >= 0 ? firstDayOfWeek - 1 : timeConstants_1.TimeConstants.DaysInOneWeek - 1;
var daysOffset = lastDayOfWeek - date.getDay();
if (daysOffset < 0) {
// If last day of week is < date, go 1 week forward, to ensure resulting date is in the future.
daysOffset += timeConstants_1.TimeConstants.DaysInOneWeek;
}
return addDays(date, daysOffset);
}
/**
* Gets a new date with the time portion zeroed out, i.e., set to midnight
* @param date - The origin date
* @returns A new date with the time set to midnight
*/
function getDatePart(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
/**
* Helper function to assist in date comparisons
*/
function getDatePartHashValue(date) {
// Generate date hash value created as sum of Date (up to 31 = 5 bits), Month (up to 11 = 4 bits) and Year.
// eslint-disable-next-line no-bitwise
return date.getDate() + (date.getMonth() << 5) + (date.getFullYear() << 9);
}
/**
* Helper function for `getWeekNumber`.
* Returns week number for a date.
* @param date - current selected date.
* @param firstDayOfWeek - The first day of week (0-6, Sunday = 0)
* @param numberOfFullDays - week settings.
* @returns The week's number in the year.
*/
function getWeekOfYearFullDays(date, firstDayOfWeek, numberOfFullDays) {
var dayOfYear = getDayOfYear(date) - 1;
var num = date.getDay() - (dayOfYear % timeConstants_1.TimeConstants.DaysInOneWeek);
var lastDayOfPrevYear = new Date(date.getFullYear() - 1, dateValues_1.MonthOfYear.December, 31);
var daysInYear = getDayOfYear(lastDayOfPrevYear) - 1;
var num2 = (firstDayOfWeek - num + 2 * timeConstants_1.TimeConstants.DaysInOneWeek) % timeConstants_1.TimeConstants.DaysInOneWeek;
if (num2 !== 0 && num2 >= numberOfFullDays) {
num2 -= timeConstants_1.TimeConstants.DaysInOneWeek;
}
var num3 = dayOfYear - num2;
if (num3 < 0) {
num -= daysInYear % timeConstants_1.TimeConstants.DaysInOneWeek;
num2 = (firstDayOfWeek - num + 2 * timeConstants_1.TimeConstants.DaysInOneWeek) % timeConstants_1.TimeConstants.DaysInOneWeek;
if (num2 !== 0 && num2 + 1 >= numberOfFullDays) {
num2 -= timeConstants_1.TimeConstants.DaysInOneWeek;
}
num3 = daysInYear - num2;
}
return Math.floor(num3 / timeConstants_1.TimeConstants.DaysInOneWeek + 1);
}
/**
* Helper function for `getWeekNumber`.
* Returns week number for a date.
* @param date - current selected date.
* @param firstDayOfWeek - The first day of week (0-6, Sunday = 0)
* @returns The week's number in the year.
*/
function getFirstDayWeekOfYear(date, firstDayOfWeek) {
var num = getDayOfYear(date) - 1;
var num2 = date.getDay() - (num % timeConstants_1.TimeConstants.DaysInOneWeek);
var num3 = (num2 - firstDayOfWeek + 2 * timeConstants_1.TimeConstants.DaysInOneWeek) % timeConstants_1.TimeConstants.DaysInOneWeek;
return Math.floor((num + num3) / timeConstants_1.TimeConstants.DaysInOneWeek + 1);
}
/**
* Helper function for `getWeekNumber`.
* Returns adjusted week day number when `firstDayOfWeek` is other than Sunday.
* For Week Day Number comparison checks
* @param firstDayOfWeek - The first day of week (0-6, Sunday = 0)
* @param dateWeekDay - shifts number forward to 1 week in case passed as true
* @returns The day of week adjusted to `firstDayOfWeek`; e.g. when `firstDayOfWeek` is Monday (1),
* Sunday becomes 7.
*/
function adjustWeekDay(firstDayOfWeek, dateWeekDay) {
return firstDayOfWeek !== dateValues_1.DayOfWeek.Sunday && dateWeekDay < firstDayOfWeek
? dateWeekDay + timeConstants_1.TimeConstants.DaysInOneWeek
: dateWeekDay;
}
/**
* Returns the day number for a date in a year:
* the number of days since January 1st in the particular year.
* @param date - A date to find the day number for.
* @returns The day's number in the year.
*/
function getDayOfYear(date) {
var month = date.getMonth();
var year = date.getFullYear();
var daysUntilDate = 0;
for (var i = 0; i < month; i++) {
daysUntilDate += daysInMonth(i + 1, year);
}
daysUntilDate += date.getDate();
return daysUntilDate;
}
/**
* Returns the number of days in the month
* @param month - The month number to target (months 1-12).
* @param year - The year to target.
* @returns The number of days in the month.
*/
function daysInMonth(month, year) {
return new Date(year, month, 0).getDate();
}
});
//# sourceMappingURL=dateMath.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
/**
* The days of the week
* {@docCategory DateTimeUtilities}
*/
export declare enum DayOfWeek {
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6
}
/**
* The months
* {@docCategory DateTimeUtilities}
*/
export declare enum MonthOfYear {
January = 0,
February = 1,
March = 2,
April = 3,
May = 4,
June = 5,
July = 6,
August = 7,
September = 8,
October = 9,
November = 10,
December = 11
}
/**
* First week of the year settings types
* {@docCategory DateTimeUtilities}
*/
export declare enum FirstWeekOfYear {
FirstDay = 0,
FirstFullWeek = 1,
FirstFourDayWeek = 2
}
/**
* The supported date range types
* {@docCategory DateTimeUtilities}
*/
export declare enum DateRangeType {
Day = 0,
Week = 1,
Month = 2,
WorkWeek = 3
}
export declare const DAYS_IN_WEEK = 7;
@@ -0,0 +1,61 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DAYS_IN_WEEK = exports.DateRangeType = exports.FirstWeekOfYear = exports.MonthOfYear = exports.DayOfWeek = void 0;
/**
* The days of the week
* {@docCategory DateTimeUtilities}
*/
var DayOfWeek;
(function (DayOfWeek) {
DayOfWeek[DayOfWeek["Sunday"] = 0] = "Sunday";
DayOfWeek[DayOfWeek["Monday"] = 1] = "Monday";
DayOfWeek[DayOfWeek["Tuesday"] = 2] = "Tuesday";
DayOfWeek[DayOfWeek["Wednesday"] = 3] = "Wednesday";
DayOfWeek[DayOfWeek["Thursday"] = 4] = "Thursday";
DayOfWeek[DayOfWeek["Friday"] = 5] = "Friday";
DayOfWeek[DayOfWeek["Saturday"] = 6] = "Saturday";
})(DayOfWeek || (exports.DayOfWeek = DayOfWeek = {}));
/**
* The months
* {@docCategory DateTimeUtilities}
*/
var MonthOfYear;
(function (MonthOfYear) {
MonthOfYear[MonthOfYear["January"] = 0] = "January";
MonthOfYear[MonthOfYear["February"] = 1] = "February";
MonthOfYear[MonthOfYear["March"] = 2] = "March";
MonthOfYear[MonthOfYear["April"] = 3] = "April";
MonthOfYear[MonthOfYear["May"] = 4] = "May";
MonthOfYear[MonthOfYear["June"] = 5] = "June";
MonthOfYear[MonthOfYear["July"] = 6] = "July";
MonthOfYear[MonthOfYear["August"] = 7] = "August";
MonthOfYear[MonthOfYear["September"] = 8] = "September";
MonthOfYear[MonthOfYear["October"] = 9] = "October";
MonthOfYear[MonthOfYear["November"] = 10] = "November";
MonthOfYear[MonthOfYear["December"] = 11] = "December";
})(MonthOfYear || (exports.MonthOfYear = MonthOfYear = {}));
/**
* First week of the year settings types
* {@docCategory DateTimeUtilities}
*/
var FirstWeekOfYear;
(function (FirstWeekOfYear) {
FirstWeekOfYear[FirstWeekOfYear["FirstDay"] = 0] = "FirstDay";
FirstWeekOfYear[FirstWeekOfYear["FirstFullWeek"] = 1] = "FirstFullWeek";
FirstWeekOfYear[FirstWeekOfYear["FirstFourDayWeek"] = 2] = "FirstFourDayWeek";
})(FirstWeekOfYear || (exports.FirstWeekOfYear = FirstWeekOfYear = {}));
/**
* The supported date range types
* {@docCategory DateTimeUtilities}
*/
var DateRangeType;
(function (DateRangeType) {
DateRangeType[DateRangeType["Day"] = 0] = "Day";
DateRangeType[DateRangeType["Week"] = 1] = "Week";
DateRangeType[DateRangeType["Month"] = 2] = "Month";
DateRangeType[DateRangeType["WorkWeek"] = 3] = "WorkWeek";
})(DateRangeType || (exports.DateRangeType = DateRangeType = {}));
exports.DAYS_IN_WEEK = 7;
});
//# sourceMappingURL=dateValues.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateValues.js","sourceRoot":"../src/","sources":["dateValues/dateValues.ts"],"names":[],"mappings":";;;;IAAA;;;OAGG;IACH,IAAY,SAQX;IARD,WAAY,SAAS;QACnB,6CAAU,CAAA;QACV,6CAAU,CAAA;QACV,+CAAW,CAAA;QACX,mDAAa,CAAA;QACb,iDAAY,CAAA;QACZ,6CAAU,CAAA;QACV,iDAAY,CAAA;IACd,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;IAED;;;OAGG;IACH,IAAY,WAaX;IAbD,WAAY,WAAW;QACrB,mDAAW,CAAA;QACX,qDAAY,CAAA;QACZ,+CAAS,CAAA;QACT,+CAAS,CAAA;QACT,2CAAO,CAAA;QACP,6CAAQ,CAAA;QACR,6CAAQ,CAAA;QACR,iDAAU,CAAA;QACV,uDAAa,CAAA;QACb,mDAAW,CAAA;QACX,sDAAa,CAAA;QACb,sDAAa,CAAA;IACf,CAAC,EAbW,WAAW,2BAAX,WAAW,QAatB;IAED;;;OAGG;IACH,IAAY,eAIX;IAJD,WAAY,eAAe;QACzB,6DAAY,CAAA;QACZ,uEAAiB,CAAA;QACjB,6EAAoB,CAAA;IACtB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;IAED;;;OAGG;IACH,IAAY,aAKX;IALD,WAAY,aAAa;QACvB,+CAAO,CAAA;QACP,iDAAQ,CAAA;QACR,mDAAS,CAAA;QACT,yDAAY,CAAA;IACd,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;IAEY,QAAA,YAAY,GAAG,CAAC,CAAC","sourcesContent":["/**\n * The days of the week\n * {@docCategory DateTimeUtilities}\n */\nexport enum DayOfWeek {\n Sunday = 0,\n Monday = 1,\n Tuesday = 2,\n Wednesday = 3,\n Thursday = 4,\n Friday = 5,\n Saturday = 6,\n}\n\n/**\n * The months\n * {@docCategory DateTimeUtilities}\n */\nexport enum MonthOfYear {\n January = 0,\n February = 1,\n March = 2,\n April = 3,\n May = 4,\n June = 5,\n July = 6,\n August = 7,\n September = 8,\n October = 9,\n November = 10,\n December = 11,\n}\n\n/**\n * First week of the year settings types\n * {@docCategory DateTimeUtilities}\n */\nexport enum FirstWeekOfYear {\n FirstDay = 0,\n FirstFullWeek = 1,\n FirstFourDayWeek = 2,\n}\n\n/**\n * The supported date range types\n * {@docCategory DateTimeUtilities}\n */\nexport enum DateRangeType {\n Day = 0,\n Week = 1,\n Month = 2,\n WorkWeek = 3,\n}\n\nexport const DAYS_IN_WEEK = 7;\n"]}
@@ -0,0 +1,22 @@
export declare const TimeConstants: {
MillisecondsInOneDay: number;
MillisecondsIn1Sec: number;
MillisecondsIn1Min: number;
MillisecondsIn30Mins: number;
MillisecondsIn1Hour: number;
MinutesInOneDay: number;
MinutesInOneHour: number;
DaysInOneWeek: number;
MonthInOneYear: number;
HoursInOneDay: number;
SecondsInOneMinute: number;
OffsetTo24HourFormat: number;
/**
* Matches a time string. Groups:
* 1. hours (with or without leading 0)
* 2. minutes
* 3. seconds (optional)
* 4. meridiem (am/pm, case-insensitive, optional)
*/
TimeFormatRegex: RegExp;
};
@@ -0,0 +1,28 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeConstants = void 0;
exports.TimeConstants = {
MillisecondsInOneDay: 86400000,
MillisecondsIn1Sec: 1000,
MillisecondsIn1Min: 60000,
MillisecondsIn30Mins: 1800000,
MillisecondsIn1Hour: 3600000,
MinutesInOneDay: 1440,
MinutesInOneHour: 60,
DaysInOneWeek: 7,
MonthInOneYear: 12,
HoursInOneDay: 24,
SecondsInOneMinute: 60,
OffsetTo24HourFormat: 12,
/**
* Matches a time string. Groups:
* 1. hours (with or without leading 0)
* 2. minutes
* 3. seconds (optional)
* 4. meridiem (am/pm, case-insensitive, optional)
*/
TimeFormatRegex: /^(\d\d?):(\d\d):?(\d\d)? ?([ap]m)?/i,
};
});
//# sourceMappingURL=timeConstants.js.map
@@ -0,0 +1 @@
{"version":3,"file":"timeConstants.js","sourceRoot":"../src/","sources":["dateValues/timeConstants.ts"],"names":[],"mappings":";;;;IAAa,QAAA,aAAa,GAAG;QAC3B,oBAAoB,EAAE,QAAQ;QAC9B,kBAAkB,EAAE,IAAI;QACxB,kBAAkB,EAAE,KAAK;QACzB,oBAAoB,EAAE,OAAO;QAC7B,mBAAmB,EAAE,OAAO;QAC5B,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,EAAE;QACpB,aAAa,EAAE,CAAC;QAChB,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,EAAE;QACjB,kBAAkB,EAAE,EAAE;QACtB,oBAAoB,EAAE,EAAE;QACxB;;;;;;WAMG;QACH,eAAe,EAAE,qCAAqC;KACvD,CAAC","sourcesContent":["export const TimeConstants = {\n MillisecondsInOneDay: 86400000,\n MillisecondsIn1Sec: 1000,\n MillisecondsIn1Min: 60000,\n MillisecondsIn30Mins: 1800000,\n MillisecondsIn1Hour: 3600000,\n MinutesInOneDay: 1440,\n MinutesInOneHour: 60,\n DaysInOneWeek: 7,\n MonthInOneYear: 12,\n HoursInOneDay: 24,\n SecondsInOneMinute: 60,\n OffsetTo24HourFormat: 12,\n /**\n * Matches a time string. Groups:\n * 1. hours (with or without leading 0)\n * 2. minutes\n * 3. seconds (optional)\n * 4. meridiem (am/pm, case-insensitive, optional)\n */\n TimeFormatRegex: /^(\\d\\d?):(\\d\\d):?(\\d\\d)? ?([ap]m)?/i,\n};\n"]}
+8
View File
@@ -0,0 +1,8 @@
export * from './dateMath/dateMath';
export * from './dateValues/dateValues';
export * from './dateValues/timeConstants';
export * from './dateFormatting/index';
export * from './dateGrid/index';
export * from './timeMath/timeMath';
export * from './timeFormatting/index';
import './version';
+12
View File
@@ -0,0 +1,12 @@
define(["require", "exports", "tslib", "./dateMath/dateMath", "./dateValues/dateValues", "./dateValues/timeConstants", "./dateFormatting/index", "./dateGrid/index", "./timeMath/timeMath", "./timeFormatting/index", "./version"], function (require, exports, tslib_1, dateMath_1, dateValues_1, timeConstants_1, index_1, index_2, timeMath_1, index_3) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
tslib_1.__exportStar(dateMath_1, exports);
tslib_1.__exportStar(dateValues_1, exports);
tslib_1.__exportStar(timeConstants_1, exports);
tslib_1.__exportStar(index_1, exports);
tslib_1.__exportStar(index_2, exports);
tslib_1.__exportStar(timeMath_1, exports);
tslib_1.__exportStar(index_3, exports);
});
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;IAAA,0CAAoC;IACpC,4CAAwC;IACxC,+CAA2C;IAC3C,uCAAuC;IACvC,uCAAiC;IACjC,0CAAoC;IACpC,uCAAuC","sourcesContent":["export * from './dateMath/dateMath';\nexport * from './dateValues/dateValues';\nexport * from './dateValues/timeConstants';\nexport * from './dateFormatting/index';\nexport * from './dateGrid/index';\nexport * from './timeMath/timeMath';\nexport * from './timeFormatting/index';\nimport './version';\n"]}
@@ -0,0 +1,7 @@
/**
* Format a date object to a localized time string using the browser's default locale
* @param date - Input date to format
* @param showSeconds - Whether to show seconds in the formatted string
* @param useHour12 - Whether to use 12-hour time
*/
export declare const formatTimeString: (date: Date, showSeconds?: boolean, useHour12?: boolean) => string;
@@ -0,0 +1,25 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTimeString = void 0;
/**
* Format a date object to a localized time string using the browser's default locale
* @param date - Input date to format
* @param showSeconds - Whether to show seconds in the formatted string
* @param useHour12 - Whether to use 12-hour time
*/
var formatTimeString = function (date, showSeconds, useHour12) {
var localeTimeString = date.toLocaleTimeString([], {
hour: 'numeric',
minute: '2-digit',
second: showSeconds ? '2-digit' : undefined,
hour12: useHour12,
});
if (!useHour12 && localeTimeString.slice(0, 2) === '24') {
localeTimeString = '00' + localeTimeString.slice(2);
}
return localeTimeString;
};
exports.formatTimeString = formatTimeString;
});
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["timeFormatting/index.ts"],"names":[],"mappings":";;;;IAAA;;;;;OAKG;IACI,IAAM,gBAAgB,GAAG,UAAC,IAAU,EAAE,WAAqB,EAAE,SAAmB;QACrF,IAAI,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE;YACjD,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YAC3C,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxD,gBAAgB,GAAG,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC;IAbW,QAAA,gBAAgB,oBAa3B","sourcesContent":["/**\n * Format a date object to a localized time string using the browser's default locale\n * @param date - Input date to format\n * @param showSeconds - Whether to show seconds in the formatted string\n * @param useHour12 - Whether to use 12-hour time\n */\nexport const formatTimeString = (date: Date, showSeconds?: boolean, useHour12?: boolean): string => {\n let localeTimeString = date.toLocaleTimeString([], {\n hour: 'numeric',\n minute: '2-digit',\n second: showSeconds ? '2-digit' : undefined,\n hour12: useHour12,\n });\n\n if (!useHour12 && localeTimeString.slice(0, 2) === '24') {\n localeTimeString = '00' + localeTimeString.slice(2);\n }\n\n return localeTimeString;\n};\n"]}
@@ -0,0 +1,23 @@
/**
* Returns a date offset from the given date by the specified number of minutes.
* @param date - The origin date
* @param minutes - The number of minutes to offset. 'minutes' can be negative.
* @returns A new Date object offset from the origin date by the given number of minutes
*/
export declare const addMinutes: (date: Date, minutes: number) => Date;
/**
* Rounds the date's minute up to the next available increment. For example, if `date` has time 1:21
* and `increments` is 5, the resulting time will be 1:25.
* @param date - Date to ceil minutes
* @param increments - Time increments
* @returns Date with ceiled minute
*/
export declare const ceilMinuteToIncrement: (date: Date, increments: number) => Date;
/**
* Returns a date object from the selected time.
* @param useHour12 - If the time picker uses 12 or 24 hour formatting
* @param dateStartAnchor - The baseline date to calculate the offset of the selected time
* @param selectedTime - A string representing the user selected time
* @returns A new date object offset from the baseDate using the selected time.
*/
export declare const getDateFromTimeSelection: (useHour12: boolean, dateStartAnchor: Date, selectedTime: string) => Date;
@@ -0,0 +1,80 @@
define(["require", "exports", "../dateValues/timeConstants"], function (require, exports, timeConstants_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateFromTimeSelection = exports.ceilMinuteToIncrement = exports.addMinutes = void 0;
/**
* Returns a date offset from the given date by the specified number of minutes.
* @param date - The origin date
* @param minutes - The number of minutes to offset. 'minutes' can be negative.
* @returns A new Date object offset from the origin date by the given number of minutes
*/
var addMinutes = function (date, minutes) {
var result = new Date(date.getTime());
result.setTime(result.getTime() + minutes * timeConstants_1.TimeConstants.MinutesInOneHour * timeConstants_1.TimeConstants.MillisecondsIn1Sec);
return result;
};
exports.addMinutes = addMinutes;
/**
* Rounds the date's minute up to the next available increment. For example, if `date` has time 1:21
* and `increments` is 5, the resulting time will be 1:25.
* @param date - Date to ceil minutes
* @param increments - Time increments
* @returns Date with ceiled minute
*/
var ceilMinuteToIncrement = function (date, increments) {
var result = new Date(date.getTime());
var minute = result.getMinutes();
if (timeConstants_1.TimeConstants.MinutesInOneHour % increments) {
result.setMinutes(0);
}
else {
var times = timeConstants_1.TimeConstants.MinutesInOneHour / increments;
for (var i = 1; i <= times; i++) {
if (minute > increments * (i - 1) && minute <= increments * i) {
minute = increments * i;
break;
}
}
result.setMinutes(minute);
}
return result;
};
exports.ceilMinuteToIncrement = ceilMinuteToIncrement;
/**
* Returns a date object from the selected time.
* @param useHour12 - If the time picker uses 12 or 24 hour formatting
* @param dateStartAnchor - The baseline date to calculate the offset of the selected time
* @param selectedTime - A string representing the user selected time
* @returns A new date object offset from the baseDate using the selected time.
*/
var getDateFromTimeSelection = function (useHour12, dateStartAnchor, selectedTime) {
var _a = timeConstants_1.TimeConstants.TimeFormatRegex.exec(selectedTime) || [], selectedHours = _a[1], selectedMinutes = _a[2], selectedSeconds = _a[3], selectedAp = _a[4];
var hours = +selectedHours;
var minutes = +selectedMinutes;
var seconds = selectedSeconds ? +selectedSeconds : 0;
if (useHour12 && selectedAp) {
if (selectedAp.toLowerCase() === 'pm' && hours !== timeConstants_1.TimeConstants.OffsetTo24HourFormat) {
hours += timeConstants_1.TimeConstants.OffsetTo24HourFormat;
}
else if (selectedAp.toLowerCase() === 'am' && hours === timeConstants_1.TimeConstants.OffsetTo24HourFormat) {
hours -= timeConstants_1.TimeConstants.OffsetTo24HourFormat;
}
}
var hoursOffset;
if (dateStartAnchor.getHours() > hours ||
(dateStartAnchor.getHours() === hours && dateStartAnchor.getMinutes() > minutes)) {
hoursOffset = timeConstants_1.TimeConstants.HoursInOneDay - dateStartAnchor.getHours() + hours;
}
else {
hoursOffset = Math.abs(dateStartAnchor.getHours() - hours);
}
var offset = timeConstants_1.TimeConstants.MillisecondsIn1Sec * timeConstants_1.TimeConstants.MinutesInOneHour * hoursOffset * timeConstants_1.TimeConstants.SecondsInOneMinute +
seconds * timeConstants_1.TimeConstants.MillisecondsIn1Sec;
var date = new Date(dateStartAnchor.getTime() + offset);
date.setMinutes(minutes);
date.setSeconds(seconds);
return date;
};
exports.getDateFromTimeSelection = getDateFromTimeSelection;
});
//# sourceMappingURL=timeMath.js.map
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
export {};
+6
View File
@@ -0,0 +1,6 @@
define(["require", "exports", "@fluentui/set-version"], function (require, exports, set_version_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
(0, set_version_1.setVersion)('@fluentui/date-time-utilities', '8.6.11');
});
//# sourceMappingURL=version.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"version.js","sourceRoot":"../src/","sources":["version.ts"],"names":[],"mappings":";;;IAGA,IAAA,wBAAU,EAAC,+BAA+B,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Do not modify this file; it is generated as part of publish.\n// The checked in version is a placeholder only and will not be updated.\nimport { setVersion } from '@fluentui/set-version';\nsetVersion('@fluentui/date-time-utilities', '8.6.11');"]}
@@ -0,0 +1,32 @@
import { IDateGridStrings, IDateFormatting, ICalendarStrings } from './dateFormatting.types';
/**
* Format date to a day string representation
* @param date - input date to format
*/
export declare const formatDay: (date: Date) => string;
/**
* Format date to a month-day-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month-year string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a month string
* @param date - input date to format
* @param strings - localized strings
*/
export declare const formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Format date to a year string representation
* @param date - input date to format
*/
export declare const formatYear: (date: Date) => string;
export declare const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings;
export declare const DEFAULT_DATE_FORMATTING: IDateFormatting;
export declare const DEFAULT_CALENDAR_STRINGS: ICalendarStrings;
@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CALENDAR_STRINGS = exports.DEFAULT_DATE_FORMATTING = exports.DEFAULT_DATE_GRID_STRINGS = exports.formatYear = exports.formatMonth = exports.formatMonthYear = exports.formatMonthDayYear = exports.formatDay = void 0;
var tslib_1 = require("tslib");
/**
* Format date to a day string representation
* @param date - input date to format
*/
var formatDay = function (date) { return date.getDate().toString(); };
exports.formatDay = formatDay;
/**
* Format date to a month-day-year string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonthDayYear = function (date, strings) {
return strings.months[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();
};
exports.formatMonthDayYear = formatMonthDayYear;
/**
* Format date to a month-year string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonthYear = function (date, strings) {
return strings.months[date.getMonth()] + ' ' + date.getFullYear();
};
exports.formatMonthYear = formatMonthYear;
/**
* Format date to a month string
* @param date - input date to format
* @param strings - localized strings
*/
var formatMonth = function (date, strings) { return strings.months[date.getMonth()]; };
exports.formatMonth = formatMonth;
/**
* Format date to a year string representation
* @param date - input date to format
*/
var formatYear = function (date) { return date.getFullYear().toString(); };
exports.formatYear = formatYear;
exports.DEFAULT_DATE_GRID_STRINGS = {
months: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
],
shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
shortDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
};
exports.DEFAULT_DATE_FORMATTING = {
formatDay: exports.formatDay,
formatMonth: exports.formatMonth,
formatYear: exports.formatYear,
formatMonthDayYear: exports.formatMonthDayYear,
formatMonthYear: exports.formatMonthYear,
};
exports.DEFAULT_CALENDAR_STRINGS = tslib_1.__assign(tslib_1.__assign({}, exports.DEFAULT_DATE_GRID_STRINGS), { goToToday: 'Go to today', weekNumberFormatString: 'Week number {0}', prevMonthAriaLabel: 'Previous month', nextMonthAriaLabel: 'Next month', prevYearAriaLabel: 'Previous year', nextYearAriaLabel: 'Next year', prevYearRangeAriaLabel: 'Previous year range', nextYearRangeAriaLabel: 'Next year range', closeButtonAriaLabel: 'Close', selectedDateFormatString: 'Selected date {0}', todayDateFormatString: "Today's date {0}", monthPickerHeaderAriaLabel: '{0}, change year', yearPickerHeaderAriaLabel: '{0}, change month', dayMarkedAriaLabel: 'marked' });
//# sourceMappingURL=dateFormatting.defaults.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateFormatting.defaults.js","sourceRoot":"../src/","sources":["dateFormatting/dateFormatting.defaults.ts"],"names":[],"mappings":";;;;AAEA;;;GAGG;AACI,IAAM,SAAS,GAAG,UAAC,IAAU,IAAa,OAAA,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAzB,CAAyB,CAAC;AAA9D,QAAA,SAAS,aAAqD;AAE3E;;;;GAIG;AACI,IAAM,kBAAkB,GAAG,UAAC,IAAU,EAAE,OAAyB;IACtE,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE;AAAlF,CAAkF,CAAC;AADxE,QAAA,kBAAkB,sBACsD;AAErF;;;;GAIG;AACI,IAAM,eAAe,GAAG,UAAC,IAAU,EAAE,OAAyB;IACnE,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE;AAA1D,CAA0D,CAAC;AADhD,QAAA,eAAe,mBACiC;AAE7D;;;;GAIG;AACI,IAAM,WAAW,GAAG,UAAC,IAAU,EAAE,OAAyB,IAAa,OAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAA/B,CAA+B,CAAC;AAAjG,QAAA,WAAW,eAAsF;AAE9G;;;GAGG;AACI,IAAM,UAAU,GAAG,UAAC,IAAU,IAAa,OAAA,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,EAA7B,CAA6B,CAAC;AAAnE,QAAA,UAAU,cAAyD;AAEnE,QAAA,yBAAyB,GAAqB;IACzD,MAAM,EAAE;QACN,SAAS;QACT,UAAU;QACV,OAAO;QACP,OAAO;QACP,KAAK;QACL,MAAM;QACN,MAAM;QACN,QAAQ;QACR,WAAW;QACX,SAAS;QACT,UAAU;QACV,UAAU;KACX;IACD,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IACjG,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC;IACpF,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;CAC/C,CAAC;AAEW,QAAA,uBAAuB,GAAoB;IACtD,SAAS,mBAAA;IACT,WAAW,qBAAA;IACX,UAAU,oBAAA;IACV,kBAAkB,4BAAA;IAClB,eAAe,yBAAA;CAChB,CAAC;AAEW,QAAA,wBAAwB,yCAChC,iCAAyB,KAE5B,SAAS,EAAE,aAAa,EACxB,sBAAsB,EAAE,iBAAiB,EACzC,kBAAkB,EAAE,gBAAgB,EACpC,kBAAkB,EAAE,YAAY,EAChC,iBAAiB,EAAE,eAAe,EAClC,iBAAiB,EAAE,WAAW,EAC9B,sBAAsB,EAAE,qBAAqB,EAC7C,sBAAsB,EAAE,iBAAiB,EACzC,oBAAoB,EAAE,OAAO,EAC7B,wBAAwB,EAAE,mBAAmB,EAC7C,qBAAqB,EAAE,kBAAkB,EACzC,0BAA0B,EAAE,kBAAkB,EAC9C,yBAAyB,EAAE,mBAAmB,EAC9C,kBAAkB,EAAE,QAAQ,IAC5B","sourcesContent":["import { IDateGridStrings, IDateFormatting, ICalendarStrings } from './dateFormatting.types';\n\n/**\n * Format date to a day string representation\n * @param date - input date to format\n */\nexport const formatDay = (date: Date): string => date.getDate().toString();\n\n/**\n * Format date to a month-day-year string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonthDayYear = (date: Date, strings: IDateGridStrings): string =>\n strings.months[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();\n\n/**\n * Format date to a month-year string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonthYear = (date: Date, strings: IDateGridStrings): string =>\n strings.months[date.getMonth()] + ' ' + date.getFullYear();\n\n/**\n * Format date to a month string\n * @param date - input date to format\n * @param strings - localized strings\n */\nexport const formatMonth = (date: Date, strings: IDateGridStrings): string => strings.months[date.getMonth()];\n\n/**\n * Format date to a year string representation\n * @param date - input date to format\n */\nexport const formatYear = (date: Date): string => date.getFullYear().toString();\n\nexport const DEFAULT_DATE_GRID_STRINGS: IDateGridStrings = {\n months: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n shortDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n};\n\nexport const DEFAULT_DATE_FORMATTING: IDateFormatting = {\n formatDay,\n formatMonth,\n formatYear,\n formatMonthDayYear,\n formatMonthYear,\n};\n\nexport const DEFAULT_CALENDAR_STRINGS: ICalendarStrings = {\n ...DEFAULT_DATE_GRID_STRINGS,\n\n goToToday: 'Go to today',\n weekNumberFormatString: 'Week number {0}',\n prevMonthAriaLabel: 'Previous month',\n nextMonthAriaLabel: 'Next month',\n prevYearAriaLabel: 'Previous year',\n nextYearAriaLabel: 'Next year',\n prevYearRangeAriaLabel: 'Previous year range',\n nextYearRangeAriaLabel: 'Next year range',\n closeButtonAriaLabel: 'Close',\n selectedDateFormatString: 'Selected date {0}',\n todayDateFormatString: \"Today's date {0}\",\n monthPickerHeaderAriaLabel: '{0}, change year',\n yearPickerHeaderAriaLabel: '{0}, change month',\n dayMarkedAriaLabel: 'marked',\n};\n"]}
@@ -0,0 +1,114 @@
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDateGridStrings {
/**
* An array of strings for the full names of months.
* The array is 0-based, so months[0] should be the full name of January.
*/
months: string[];
/**
* An array of strings for the short names of months.
* The array is 0-based, so shortMonths[0] should be the short name of January.
*/
shortMonths: string[];
/**
* An array of strings for the full names of days of the week.
* The array is 0-based, so days[0] should be the full name of Sunday.
*/
days: string[];
/**
* An array of strings for the initials of the days of the week.
* The array is 0-based, so days[0] should be the initial of Sunday.
*/
shortDays: string[];
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDateFormatting {
/**
* Get a localized string for a day.
*/
formatDay: (date: Date) => string;
/**
* Get a localized string for a month.
*/
formatMonth: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a year.
*/
formatYear: (date: Date) => string;
/**
* Get a localized string for a month, day, and year.
*/
formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;
/**
* Get a localized string for a month and year.
*/
formatMonthYear: (date: Date, strings: IDateGridStrings) => string;
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface ICalendarStrings extends IDateGridStrings {
/**
* String to render for button to direct the user to today's date.
*/
goToToday: string;
/**
* Aria-label for the "previous month" button in day picker.
*/
prevMonthAriaLabel?: string;
/**
* Aria-label for the "next month" button in day picker.
*/
nextMonthAriaLabel?: string;
/**
* Aria-label for the "previous year" button in month picker.
*/
prevYearAriaLabel?: string;
/**
* Aria-label for the "next year" button in month picker.
*/
nextYearAriaLabel?: string;
/**
* Aria-label for the "previous year range" button in year picker.
*/
prevYearRangeAriaLabel?: string;
/**
* Aria-label for the "next year range" button in year picker.
*/
nextYearRangeAriaLabel?: string;
/**
* Aria-label format string for the header button in the month picker. Should have 1 string param, e.g. "`{0}`,
* select to change the year". This aria-label will only be applied if the year picker is enabled; otherwise
* the label will default to the header string, e.g. "2019".
*/
monthPickerHeaderAriaLabel?: string;
/**
* Aria-label format string for the header button in the year picker.
* Should have 1 string param, e.g. "`{0}`, select to change the month"
*/
yearPickerHeaderAriaLabel?: string;
/**
* Aria-label for the "close" button.
*/
closeButtonAriaLabel?: string;
/**
* Aria-label format string for the week number header. Should have 1 string param, e.g. "week number `{0}`"
*/
weekNumberFormatString?: string;
/**
* Aria-label format string for the currently selected date. Should have 1 string param, e.g. "Selected date `{0}`"
*/
selectedDateFormatString?: string;
/**
* Aria-label format string for today's date. Should have 1 string param, e.g. "Today's date `{0}`"
*/
todayDateFormatString?: string;
/**
* Aria-label for when a date is marked
*/
dayMarkedAriaLabel?: string;
}
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=dateFormatting.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateFormatting.types.js","sourceRoot":"../src/","sources":["dateFormatting/dateFormatting.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDateGridStrings {\n /**\n * An array of strings for the full names of months.\n * The array is 0-based, so months[0] should be the full name of January.\n */\n months: string[];\n\n /**\n * An array of strings for the short names of months.\n * The array is 0-based, so shortMonths[0] should be the short name of January.\n */\n shortMonths: string[];\n\n /**\n * An array of strings for the full names of days of the week.\n * The array is 0-based, so days[0] should be the full name of Sunday.\n */\n days: string[];\n\n /**\n * An array of strings for the initials of the days of the week.\n * The array is 0-based, so days[0] should be the initial of Sunday.\n */\n shortDays: string[];\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDateFormatting {\n /**\n * Get a localized string for a day.\n */\n formatDay: (date: Date) => string;\n\n /**\n * Get a localized string for a month.\n */\n formatMonth: (date: Date, strings: IDateGridStrings) => string;\n\n /**\n * Get a localized string for a year.\n */\n formatYear: (date: Date) => string;\n\n /**\n * Get a localized string for a month, day, and year.\n */\n formatMonthDayYear: (date: Date, strings: IDateGridStrings) => string;\n\n /**\n * Get a localized string for a month and year.\n */\n formatMonthYear: (date: Date, strings: IDateGridStrings) => string;\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface ICalendarStrings extends IDateGridStrings {\n /**\n * String to render for button to direct the user to today's date.\n */\n goToToday: string;\n\n /**\n * Aria-label for the \"previous month\" button in day picker.\n */\n prevMonthAriaLabel?: string;\n\n /**\n * Aria-label for the \"next month\" button in day picker.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Aria-label for the \"previous year\" button in month picker.\n */\n prevYearAriaLabel?: string;\n\n /**\n * Aria-label for the \"next year\" button in month picker.\n */\n nextYearAriaLabel?: string;\n\n /**\n * Aria-label for the \"previous year range\" button in year picker.\n */\n prevYearRangeAriaLabel?: string;\n\n /**\n * Aria-label for the \"next year range\" button in year picker.\n */\n nextYearRangeAriaLabel?: string;\n\n /**\n * Aria-label format string for the header button in the month picker. Should have 1 string param, e.g. \"`{0}`,\n * select to change the year\". This aria-label will only be applied if the year picker is enabled; otherwise\n * the label will default to the header string, e.g. \"2019\".\n */\n monthPickerHeaderAriaLabel?: string;\n\n /**\n * Aria-label format string for the header button in the year picker.\n * Should have 1 string param, e.g. \"`{0}`, select to change the month\"\n */\n yearPickerHeaderAriaLabel?: string;\n\n /**\n * Aria-label for the \"close\" button.\n */\n closeButtonAriaLabel?: string;\n\n /**\n * Aria-label format string for the week number header. Should have 1 string param, e.g. \"week number `{0}`\"\n */\n weekNumberFormatString?: string;\n\n /**\n * Aria-label format string for the currently selected date. Should have 1 string param, e.g. \"Selected date `{0}`\"\n */\n selectedDateFormatString?: string;\n\n /**\n * Aria-label format string for today's date. Should have 1 string param, e.g. \"Today's date `{0}`\"\n */\n todayDateFormatString?: string;\n\n /**\n * Aria-label for when a date is marked\n */\n dayMarkedAriaLabel?: string;\n}\n"]}
@@ -0,0 +1,2 @@
export * from './dateFormatting.types';
export * from './dateFormatting.defaults';
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./dateFormatting.types"), exports);
tslib_1.__exportStar(require("./dateFormatting.defaults"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateFormatting/index.ts"],"names":[],"mappings":";;;AAAA,iEAAuC;AACvC,oEAA0C","sourcesContent":["export * from './dateFormatting.types';\nexport * from './dateFormatting.defaults';\n"]}
@@ -0,0 +1,98 @@
import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';
export interface IDay {
/** `Date.toString()` value of current date */
key: string;
/** `Date.getDate()` value of current date */
date: string;
/** `Date` object of current date */
originalDate: Date;
/** Is current date is in the same month as "today" date */
isInMonth: boolean;
/** Is current date is "today" date */
isToday: boolean;
/** Is current date is selected */
isSelected: boolean;
/** Is current date within restriction boundaries */
isInBounds: boolean;
/** Is current date marked */
isMarked: boolean;
}
export interface IAvailableDateOptions extends IRestrictedDatesOptions {
/** Date from which we start the search */
initialDate: Date;
/** Ideal available date */
targetDate: Date;
/** Direction of search (`1` - search in future / `-1` search in past) */
direction: number;
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IRestrictedDatesOptions {
/**
* If set the Calendar will not allow navigation to or selection of a date earlier than this value.
*/
minDate?: Date;
/**
* If set the Calendar will not allow navigation to or selection of a date later than this value.
*/
maxDate?: Date;
/**
* If set the Calendar will not allow selection of dates in this array.
*/
restrictedDates?: Date[];
}
/**
* {@docCategory DateTimeUtilities}
*/
export interface IDayGridOptions extends IRestrictedDatesOptions {
/**
* The first day of the week for your locale.
*/
firstDayOfWeek: DayOfWeek;
/**
* Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,
* FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
*/
firstWeekOfYear: FirstWeekOfYear;
/**
* The date range type indicating how many days should be selected as the user
* selects days
*/
dateRangeType: DateRangeType;
/**
* The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day
* views.
*/
daysToSelectInDayView?: number;
/**
* Value of today. If unspecified, current time in client machine will be used.
*/
today?: Date;
/**
* Whether the calendar should show the week number (weeks 1 to 53) before each week row
*/
showWeekNumbers?: boolean;
/**
* The days that are selectable when `dateRangeType` is WorkWeek.
* If `dateRangeType` is not WorkWeek this property does nothing.
*/
workWeekDays?: DayOfWeek[];
/**
* Which days in the generated grid should be marked.
*/
markedDays?: Date[];
/**
* The currently selected date
*/
selectedDate: Date;
/**
* The currently navigated date
*/
navigatedDate: Date;
/**
* How many weeks to show by default. If not provided, will show enough weeks to display the current
* month, between 4 and 6 depending
*/
weeksToShow?: number;
}
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=dateGrid.types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"dateGrid.types.js","sourceRoot":"../src/","sources":["dateGrid/dateGrid.types.ts"],"names":[],"mappings":"","sourcesContent":["import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../dateValues/dateValues';\n\nexport interface IDay {\n /** `Date.toString()` value of current date */\n key: string;\n /** `Date.getDate()` value of current date */\n date: string;\n /** `Date` object of current date */\n originalDate: Date;\n /** Is current date is in the same month as \"today\" date */\n isInMonth: boolean;\n /** Is current date is \"today\" date */\n isToday: boolean;\n /** Is current date is selected */\n isSelected: boolean;\n /** Is current date within restriction boundaries */\n isInBounds: boolean;\n /** Is current date marked */\n isMarked: boolean;\n}\n\nexport interface IAvailableDateOptions extends IRestrictedDatesOptions {\n /** Date from which we start the search */\n initialDate: Date;\n /** Ideal available date */\n targetDate: Date;\n /** Direction of search (`1` - search in future / `-1` search in past) */\n direction: number;\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IRestrictedDatesOptions {\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n}\n\n/**\n * {@docCategory DateTimeUtilities}\n */\nexport interface IDayGridOptions extends IRestrictedDatesOptions {\n /**\n * The first day of the week for your locale.\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n */\n showWeekNumbers?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Which days in the generated grid should be marked.\n */\n markedDays?: Date[];\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n */\n weeksToShow?: number;\n}\n"]}
@@ -0,0 +1,6 @@
import { IAvailableDateOptions } from './dateGrid.types';
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
export declare const findAvailableDate: (options: IAvailableDateOptions) => Date | undefined;
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findAvailableDate = void 0;
var tslib_1 = require("tslib");
var isRestrictedDate_1 = require("./isRestrictedDate");
var isAfterMaxDate_1 = require("./isAfterMaxDate");
var isBeforeMinDate_1 = require("./isBeforeMinDate");
var dateMath_1 = require("../dateMath/dateMath");
/**
* Returns closest available date given the restriction `options`, or undefined otherwise
* @param options - list of search options
*/
var findAvailableDate = function (options) {
var targetDate = options.targetDate, initialDate = options.initialDate, direction = options.direction, restrictedDateOptions = tslib_1.__rest(options, ["targetDate", "initialDate", "direction"]);
var availableDate = targetDate;
// if the target date is available, return it immediately
if (!(0, isRestrictedDate_1.isRestrictedDate)(targetDate, restrictedDateOptions)) {
return targetDate;
}
while ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 &&
(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions) &&
!(0, isAfterMaxDate_1.isAfterMaxDate)(availableDate, restrictedDateOptions) &&
!(0, isBeforeMinDate_1.isBeforeMinDate)(availableDate, restrictedDateOptions)) {
availableDate = (0, dateMath_1.addDays)(availableDate, direction);
}
if ((0, dateMath_1.compareDatePart)(initialDate, availableDate) !== 0 && !(0, isRestrictedDate_1.isRestrictedDate)(availableDate, restrictedDateOptions)) {
return availableDate;
}
return undefined;
};
exports.findAvailableDate = findAvailableDate;
//# sourceMappingURL=findAvailableDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"findAvailableDate.js","sourceRoot":"../src/","sources":["dateGrid/findAvailableDate.ts"],"names":[],"mappings":";;;;AAEA,uDAAsD;AAEtD,mDAAkD;AAElD,qDAAoD;AACpD,iDAAgE;AAEhE;;;GAGG;AACI,IAAM,iBAAiB,GAAG,UAAC,OAA8B;IACtD,IAAA,UAAU,GAAuD,OAAO,WAA9D,EAAE,WAAW,GAA0C,OAAO,YAAjD,EAAE,SAAS,GAA+B,OAAO,UAAtC,EAAK,qBAAqB,kBAAK,OAAO,EAA1E,0CAAgE,CAAF,CAAa;IACjF,IAAI,aAAa,GAAG,UAAU,CAAC;IAC/B,yDAAyD;IACzD,IAAI,CAAC,IAAA,mCAAgB,EAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACzD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OACE,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC;QACjD,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC;QACtD,CAAC,IAAA,+BAAc,EAAC,aAAa,EAAE,qBAAqB,CAAC;QACrD,CAAC,IAAA,iCAAe,EAAC,aAAa,EAAE,qBAAqB,CAAC,EACtD,CAAC;QACD,aAAa,GAAG,IAAA,kBAAO,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,IAAA,0BAAe,EAAC,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,mCAAgB,EAAC,aAAa,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACjH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAtBW,QAAA,iBAAiB,qBAsB5B","sourcesContent":["import { IAvailableDateOptions } from './dateGrid.types';\n\nimport { isRestrictedDate } from './isRestrictedDate';\n\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { compareDatePart, addDays } from '../dateMath/dateMath';\n\n/**\n * Returns closest available date given the restriction `options`, or undefined otherwise\n * @param options - list of search options\n */\nexport const findAvailableDate = (options: IAvailableDateOptions): Date | undefined => {\n const { targetDate, initialDate, direction, ...restrictedDateOptions } = options;\n let availableDate = targetDate;\n // if the target date is available, return it immediately\n if (!isRestrictedDate(targetDate, restrictedDateOptions)) {\n return targetDate;\n }\n\n while (\n compareDatePart(initialDate, availableDate) !== 0 &&\n isRestrictedDate(availableDate, restrictedDateOptions) &&\n !isAfterMaxDate(availableDate, restrictedDateOptions) &&\n !isBeforeMinDate(availableDate, restrictedDateOptions)\n ) {\n availableDate = addDays(availableDate, direction);\n }\n\n if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {\n return availableDate;\n }\n\n return undefined;\n};\n"]}
@@ -0,0 +1,7 @@
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
export declare const getBoundedDateRange: (dateRange: Date[], minDate?: Date, maxDate?: Date) => Date[];
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBoundedDateRange = void 0;
var tslib_1 = require("tslib");
var dateMath_1 = require("../dateMath/dateMath");
/**
* Generates a list of dates, bounded by min and max dates
* @param dateRange - input date range
* @param minDate - min date to limit the range
* @param maxDate - max date to limit the range
*/
var getBoundedDateRange = function (dateRange, minDate, maxDate) {
var boundedDateRange = tslib_1.__spreadArray([], dateRange, true);
if (minDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, minDate) >= 0; });
}
if (maxDate) {
boundedDateRange = boundedDateRange.filter(function (date) { return (0, dateMath_1.compareDatePart)(date, maxDate) <= 0; });
}
return boundedDateRange;
};
exports.getBoundedDateRange = getBoundedDateRange;
//# sourceMappingURL=getBoundedDateRange.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getBoundedDateRange.js","sourceRoot":"../src/","sources":["dateGrid/getBoundedDateRange.ts"],"names":[],"mappings":";;;;AAAA,iDAAuD;AAEvD;;;;;GAKG;AACI,IAAM,mBAAmB,GAAG,UAAC,SAAiB,EAAE,OAAc,EAAE,OAAc;IACnF,IAAI,gBAAgB,6BAAO,SAAS,OAAC,CAAC;IACtC,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;IAC1G,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,UAAC,IAAU,IAAK,OAAA,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAe,CAAC,IAAI,CAAC,EAA3C,CAA2C,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B","sourcesContent":["import { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Generates a list of dates, bounded by min and max dates\n * @param dateRange - input date range\n * @param minDate - min date to limit the range\n * @param maxDate - max date to limit the range\n */\nexport const getBoundedDateRange = (dateRange: Date[], minDate?: Date, maxDate?: Date): Date[] => {\n let boundedDateRange = [...dateRange];\n if (minDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, minDate as Date) >= 0);\n }\n if (maxDate) {\n boundedDateRange = boundedDateRange.filter((date: Date) => compareDatePart(date, maxDate as Date) <= 0);\n }\n return boundedDateRange;\n};\n"]}
@@ -0,0 +1,9 @@
import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
export declare const getDateRangeTypeToUse: (dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined, firstDayOfWeek: DayOfWeek) => DateRangeType;
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDateRangeTypeToUse = void 0;
var dateValues_1 = require("../dateValues/dateValues");
var isContiguous_1 = require("./isContiguous");
/**
* Return corrected date range type, given `dateRangeType` and list of working days.
* For non-contiguous working days and working week range type, returns general week range type.
* For other cases returns input date range type.
* @param dateRangeType - input type of range
* @param workWeekDays - list of working days in a week
*/
var getDateRangeTypeToUse = function (dateRangeType, workWeekDays, firstDayOfWeek) {
if (workWeekDays && dateRangeType === dateValues_1.DateRangeType.WorkWeek) {
if (!(0, isContiguous_1.isContiguous)(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {
return dateValues_1.DateRangeType.Week;
}
}
return dateRangeType;
};
exports.getDateRangeTypeToUse = getDateRangeTypeToUse;
//# sourceMappingURL=getDateRangeTypeToUse.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getDateRangeTypeToUse.js","sourceRoot":"../src/","sources":["dateGrid/getDateRangeTypeToUse.ts"],"names":[],"mappings":";;;AAAA,uDAAoE;AACpE,+CAA8C;AAC9C;;;;;;GAMG;AACI,IAAM,qBAAqB,GAAG,UACnC,aAA4B,EAC5B,YAAqC,EACrC,cAAyB;IAEzB,IAAI,YAAY,IAAI,aAAa,KAAK,0BAAa,CAAC,QAAQ,EAAE,CAAC;QAC7D,IAAI,CAAC,IAAA,2BAAY,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnF,OAAO,0BAAa,CAAC,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAZW,QAAA,qBAAqB,yBAYhC","sourcesContent":["import { DateRangeType, DayOfWeek } from '../dateValues/dateValues';\nimport { isContiguous } from './isContiguous';\n/**\n * Return corrected date range type, given `dateRangeType` and list of working days.\n * For non-contiguous working days and working week range type, returns general week range type.\n * For other cases returns input date range type.\n * @param dateRangeType - input type of range\n * @param workWeekDays - list of working days in a week\n */\nexport const getDateRangeTypeToUse = (\n dateRangeType: DateRangeType,\n workWeekDays: DayOfWeek[] | undefined,\n firstDayOfWeek: DayOfWeek,\n): DateRangeType => {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n if (!isContiguous(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n};\n"]}
@@ -0,0 +1,8 @@
import { IDay, IDayGridOptions } from './dateGrid.types';
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
export declare const getDayGrid: (options: IDayGridOptions) => IDay[][];
@@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDayGrid = void 0;
var dateMath_1 = require("../dateMath/dateMath");
var dateValues_1 = require("../dateValues/dateValues");
var getDateRangeTypeToUse_1 = require("./getDateRangeTypeToUse");
var getBoundedDateRange_1 = require("./getBoundedDateRange");
var isRestrictedDate_1 = require("./isRestrictedDate");
/**
* Generates a grid of days, given the `options`.
* Returns one additional week at the begining from the previous range
* and one at the end from the future range
* @param options - parameters to specify date related restrictions for the resulting grid
*/
var getDayGrid = function (options) {
var selectedDate = options.selectedDate, dateRangeType = options.dateRangeType, firstDayOfWeek = options.firstDayOfWeek, today = options.today, minDate = options.minDate, maxDate = options.maxDate, weeksToShow = options.weeksToShow, workWeekDays = options.workWeekDays, daysToSelectInDayView = options.daysToSelectInDayView, restrictedDates = options.restrictedDates, markedDays = options.markedDays;
var restrictedDateOptions = { minDate: minDate, maxDate: maxDate, restrictedDates: restrictedDates };
var todaysDate = today || new Date();
var navigatedDate = options.navigatedDate ? options.navigatedDate : todaysDate;
var date;
if (weeksToShow && weeksToShow <= 4) {
// if showing less than a full month, just use date == navigatedDate
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), navigatedDate.getDate());
}
else {
date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);
}
var weeks = [];
// Cycle the date backwards to get to the first day of the week.
while (date.getDay() !== firstDayOfWeek) {
date.setDate(date.getDate() - 1);
}
// add the transition week as last week of previous range
date = (0, dateMath_1.addDays)(date, -dateValues_1.DAYS_IN_WEEK);
// a flag to indicate whether all days of the week are outside the month
var isAllDaysOfWeekOutOfMonth = false;
// in work week view if the days aren't contiguous we use week view instead
var selectedDateRangeType = (0, getDateRangeTypeToUse_1.getDateRangeTypeToUse)(dateRangeType, workWeekDays, firstDayOfWeek);
var selectedDates = [];
if (selectedDate) {
selectedDates = (0, dateMath_1.getDateRangeArray)(selectedDate, selectedDateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);
selectedDates = (0, getBoundedDateRange_1.getBoundedDateRange)(selectedDates, minDate, maxDate);
}
var shouldGetWeeks = true;
for (var weekIndex = 0; shouldGetWeeks; weekIndex++) {
var week = [];
isAllDaysOfWeekOutOfMonth = true;
var _loop_1 = function (dayIndex) {
var originalDate = new Date(date.getTime());
var dayInfo = {
key: date.toString(),
date: date.getDate().toString(),
originalDate: originalDate,
isInMonth: date.getMonth() === navigatedDate.getMonth(),
isToday: (0, dateMath_1.compareDates)(todaysDate, date),
isSelected: (0, dateMath_1.isInDateRangeArray)(date, selectedDates),
isInBounds: !(0, isRestrictedDate_1.isRestrictedDate)(date, restrictedDateOptions),
isMarked: (markedDays === null || markedDays === void 0 ? void 0 : markedDays.some(function (markedDay) { return (0, dateMath_1.compareDates)(originalDate, markedDay); })) || false,
};
week.push(dayInfo);
if (dayInfo.isInMonth) {
isAllDaysOfWeekOutOfMonth = false;
}
date.setDate(date.getDate() + 1);
};
for (var dayIndex = 0; dayIndex < dateValues_1.DAYS_IN_WEEK; dayIndex++) {
_loop_1(dayIndex);
}
// We append the condition of the loop depending upon the showSixWeeksByDefault prop.
shouldGetWeeks = weeksToShow ? weekIndex < weeksToShow + 1 : !isAllDaysOfWeekOutOfMonth || weekIndex === 0;
// we don't check shouldGetWeeks before pushing because we want to add one extra week for transition state
weeks.push(week);
}
return weeks;
};
exports.getDayGrid = getDayGrid;
//# sourceMappingURL=getDayGrid.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
export * from './dateGrid.types';
export * from './findAvailableDate';
export * from './getBoundedDateRange';
export * from './getDateRangeTypeToUse';
export * from './getDayGrid';
export * from './isAfterMaxDate';
export * from './isBeforeMinDate';
export * from './isRestrictedDate';
export * from './isContiguous';
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./dateGrid.types"), exports);
tslib_1.__exportStar(require("./findAvailableDate"), exports);
tslib_1.__exportStar(require("./getBoundedDateRange"), exports);
tslib_1.__exportStar(require("./getDateRangeTypeToUse"), exports);
tslib_1.__exportStar(require("./getDayGrid"), exports);
tslib_1.__exportStar(require("./isAfterMaxDate"), exports);
tslib_1.__exportStar(require("./isBeforeMinDate"), exports);
tslib_1.__exportStar(require("./isRestrictedDate"), exports);
tslib_1.__exportStar(require("./isContiguous"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["dateGrid/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,8DAAoC;AACpC,gEAAsC;AACtC,kEAAwC;AACxC,uDAA6B;AAC7B,2DAAiC;AACjC,4DAAkC;AAClC,6DAAmC;AACnC,yDAA+B","sourcesContent":["export * from './dateGrid.types';\nexport * from './findAvailableDate';\nexport * from './getBoundedDateRange';\nexport * from './getDateRangeTypeToUse';\nexport * from './getDayGrid';\nexport * from './isAfterMaxDate';\nexport * from './isBeforeMinDate';\nexport * from './isRestrictedDate';\nexport * from './isContiguous';\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
export declare const isAfterMaxDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAfterMaxDate = void 0;
var dateMath_1 = require("../dateMath/dateMath");
/**
* Checks if `date` happens later than max date
* @param date - date to check
* @param options - object with max date to check against
*/
var isAfterMaxDate = function (date, options) {
var maxDate = options.maxDate;
return maxDate ? (0, dateMath_1.compareDatePart)(date, maxDate) >= 1 : false;
};
exports.isAfterMaxDate = isAfterMaxDate;
//# sourceMappingURL=isAfterMaxDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isAfterMaxDate.js","sourceRoot":"../src/","sources":["dateGrid/isAfterMaxDate.ts"],"names":[],"mappings":";;;AACA,iDAAuD;AAEvD;;;;GAIG;AACI,IAAM,cAAc,GAAG,UAAC,IAAU,EAAE,OAAgC;IACjE,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;IAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB","sourcesContent":["import { IRestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens later than max date\n * @param date - date to check\n * @param options - object with max date to check against\n */\nexport const isAfterMaxDate = (date: Date, options: IRestrictedDatesOptions): boolean => {\n const { maxDate } = options;\n return maxDate ? compareDatePart(date, maxDate) >= 1 : false;\n};\n"]}
@@ -0,0 +1,7 @@
import { IRestrictedDatesOptions } from './dateGrid.types';
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
export declare const isBeforeMinDate: (date: Date, options: IRestrictedDatesOptions) => boolean;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBeforeMinDate = void 0;
var dateMath_1 = require("../dateMath/dateMath");
/**
* Checks if `date` happens earlier than min date
* @param date - date to check
* @param options - object with min date to check against
*/
var isBeforeMinDate = function (date, options) {
var minDate = options.minDate;
return minDate ? (0, dateMath_1.compareDatePart)(minDate, date) >= 1 : false;
};
exports.isBeforeMinDate = isBeforeMinDate;
//# sourceMappingURL=isBeforeMinDate.js.map

Some files were not shown because too many files have changed in this diff Show More