@imihai/angular-datetime-picker 21.0.0 → 21.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/assets/style/picker.min.css +1 -0
  2. package/fesm2022/imihai-angular-datetime-picker.mjs +5845 -0
  3. package/fesm2022/imihai-angular-datetime-picker.mjs.map +1 -0
  4. package/imihai-angular-datetime-picker-21.0.2.tgz +0 -0
  5. package/package.json +33 -77
  6. package/types/imihai-angular-datetime-picker.d.ts +2193 -0
  7. package/.browserslistrc +0 -9
  8. package/.editorconfig +0 -13
  9. package/.eslintrc.js +0 -208
  10. package/.github/workflows/ci_test.yml +0 -35
  11. package/.prettierrc +0 -2
  12. package/.travis.yml +0 -16
  13. package/LICENSE +0 -22
  14. package/README.md +0 -194
  15. package/angular.json +0 -221
  16. package/e2e/protractor.conf.js +0 -28
  17. package/e2e/src/app.e2e-spec.ts +0 -14
  18. package/e2e/src/app.po.ts +0 -11
  19. package/e2e/tsconfig.e2e.json +0 -13
  20. package/projects/picker/karma.conf.js +0 -62
  21. package/projects/picker/ng-package.json +0 -7
  22. package/projects/picker/package.json +0 -28
  23. package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +0 -313
  24. package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +0 -18
  25. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +0 -307
  26. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +0 -11
  27. package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +0 -31
  28. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +0 -356
  29. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +0 -14
  30. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +0 -26
  31. package/projects/picker/src/lib/date-time/calendar-body.component.html +0 -38
  32. package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
  33. package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +0 -120
  34. package/projects/picker/src/lib/date-time/calendar-body.component.ts +0 -190
  35. package/projects/picker/src/lib/date-time/calendar-month-view.component.html +0 -47
  36. package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +0 -16
  37. package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +0 -394
  38. package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +0 -705
  39. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +0 -44
  40. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
  41. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +0 -343
  42. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +0 -465
  43. package/projects/picker/src/lib/date-time/calendar-year-view.component.html +0 -16
  44. package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
  45. package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +0 -381
  46. package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +0 -549
  47. package/projects/picker/src/lib/date-time/calendar.component.html +0 -169
  48. package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
  49. package/projects/picker/src/lib/date-time/calendar.component.spec.ts +0 -592
  50. package/projects/picker/src/lib/date-time/calendar.component.ts +0 -496
  51. package/projects/picker/src/lib/date-time/date-time-inline.component.html +0 -1
  52. package/projects/picker/src/lib/date-time/date-time-inline.component.scss +0 -4
  53. package/projects/picker/src/lib/date-time/date-time-inline.component.ts +0 -365
  54. package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +0 -4
  55. package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +0 -126
  56. package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
  57. package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +0 -631
  58. package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +0 -851
  59. package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +0 -76
  60. package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +0 -88
  61. package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
  62. package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
  63. package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +0 -2648
  64. package/projects/picker/src/lib/date-time/date-time-picker.component.ts +0 -731
  65. package/projects/picker/src/lib/date-time/date-time.class.ts +0 -256
  66. package/projects/picker/src/lib/date-time/date-time.module.ts +0 -61
  67. package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +0 -28
  68. package/projects/picker/src/lib/date-time/options-provider.ts +0 -44
  69. package/projects/picker/src/lib/date-time/timer-box.component.html +0 -79
  70. package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
  71. package/projects/picker/src/lib/date-time/timer-box.component.ts +0 -175
  72. package/projects/picker/src/lib/date-time/timer.component.html +0 -58
  73. package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
  74. package/projects/picker/src/lib/date-time/timer.component.spec.ts +0 -399
  75. package/projects/picker/src/lib/date-time/timer.component.ts +0 -371
  76. package/projects/picker/src/lib/dialog/dialog-config.class.ts +0 -220
  77. package/projects/picker/src/lib/dialog/dialog-container.component.html +0 -1
  78. package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
  79. package/projects/picker/src/lib/dialog/dialog-container.component.ts +0 -231
  80. package/projects/picker/src/lib/dialog/dialog-ref.class.ts +0 -178
  81. package/projects/picker/src/lib/dialog/dialog.module.ts +0 -25
  82. package/projects/picker/src/lib/dialog/dialog.service.ts +0 -353
  83. package/projects/picker/src/lib/utils/array.utils.ts +0 -12
  84. package/projects/picker/src/lib/utils/constants.ts +0 -59
  85. package/projects/picker/src/lib/utils/date.utils.ts +0 -97
  86. package/projects/picker/src/lib/utils/index.ts +0 -5
  87. package/projects/picker/src/lib/utils/object.utils.ts +0 -29
  88. package/projects/picker/src/public_api.ts +0 -56
  89. package/projects/picker/src/sass/picker.scss +0 -743
  90. package/projects/picker/src/test-helpers.ts +0 -125
  91. package/projects/picker/src/test.ts +0 -52
  92. package/projects/picker/tsconfig.lib.json +0 -18
  93. package/projects/picker/tsconfig.lib.prod.json +0 -7
  94. package/projects/picker/tsconfig.spec.json +0 -17
  95. package/projects/picker/tslint.json +0 -8
  96. package/src/app/app.component.html +0 -77
  97. package/src/app/app.component.scss +0 -32
  98. package/src/app/app.component.spec.ts +0 -16
  99. package/src/app/app.component.ts +0 -35
  100. package/src/assets/.gitkeep +0 -0
  101. package/src/environments/environment.prod.ts +0 -3
  102. package/src/environments/environment.ts +0 -16
  103. package/src/favicon.ico +0 -0
  104. package/src/index.html +0 -14
  105. package/src/karma.conf.js +0 -31
  106. package/src/main.ts +0 -16
  107. package/src/polyfills.ts +0 -53
  108. package/src/styles.scss +0 -7
  109. package/src/test.ts +0 -50
  110. package/src/tsconfig.app.json +0 -16
  111. package/src/tsconfig.spec.json +0 -18
  112. package/src/tslint.json +0 -17
  113. package/tsconfig.base.json +0 -29
  114. package/tsconfig.json +0 -30
  115. package/tslint.json +0 -130
package/angular.json DELETED
@@ -1,221 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
- "version": 1,
4
- "cli": {
5
- "cache": {
6
- "enabled": true,
7
- "path": ".cache",
8
- "environment": "all"
9
- },
10
- "analytics": false
11
- },
12
- "newProjectRoot": "projects",
13
- "projects": {
14
- "date-time-picker-app": {
15
- "root": "",
16
- "sourceRoot": "src",
17
- "projectType": "application",
18
- "prefix": "owl",
19
- "schematics": {
20
- "@schematics/angular:component": {
21
- "style": "scss"
22
- }
23
- },
24
- "architect": {
25
- "build": {
26
- "builder": "@angular/build:application",
27
- "options": {
28
- "allowedCommonJsDependencies": [
29
- "moment-timezone"
30
- ],
31
- "aot": true,
32
- "outputPath": {
33
- "base": "dist/date-time-picker-app"
34
- },
35
- "index": "src/index.html",
36
- "polyfills": [
37
- "src/polyfills.ts"
38
- ],
39
- "tsConfig": "src/tsconfig.app.json",
40
- "assets": [
41
- "src/favicon.ico",
42
- "src/assets"
43
- ],
44
- "styles": [
45
- "src/styles.scss"
46
- ],
47
- "scripts": [],
48
- "browser": "src/main.ts"
49
- },
50
- "configurations": {
51
- "production": {
52
- "fileReplacements": [
53
- {
54
- "replace": "src/environments/environment.ts",
55
- "with": "src/environments/environment.prod.ts"
56
- }
57
- ],
58
- "optimization": true,
59
- "outputHashing": "all",
60
- "sourceMap": false,
61
- "namedChunks": false,
62
- "aot": true,
63
- "extractLicenses": true,
64
- "budgets": [
65
- {
66
- "type": "initial",
67
- "maximumWarning": "2mb",
68
- "maximumError": "5mb"
69
- },
70
- {
71
- "type": "anyComponentStyle",
72
- "maximumWarning": "6kb"
73
- }
74
- ]
75
- }
76
- }
77
- },
78
- "serve": {
79
- "builder": "@angular/build:dev-server",
80
- "options": {
81
- "buildTarget": "date-time-picker-app:build"
82
- },
83
- "configurations": {
84
- "production": {
85
- "buildTarget": "date-time-picker-app:build:production"
86
- }
87
- }
88
- },
89
- "extract-i18n": {
90
- "builder": "@angular-devkit/build-angular:extract-i18n",
91
- "options": {
92
- "buildTarget": "date-time-picker-app:build"
93
- }
94
- },
95
- "test": {
96
- "builder": "@angular-devkit/build-angular:karma",
97
- "options": {
98
- "main": "src/test.ts",
99
- "polyfills": "src/polyfills.ts",
100
- "tsConfig": "src/tsconfig.spec.json",
101
- "karmaConfig": "src/karma.conf.js",
102
- "styles": [
103
- "src/styles.scss"
104
- ],
105
- "scripts": [],
106
- "assets": [
107
- "src/favicon.ico",
108
- "src/assets"
109
- ]
110
- }
111
- },
112
- "lint": {
113
- "builder": "@angular-devkit/build-angular:tslint",
114
- "options": {
115
- "tsConfig": [
116
- "src/tsconfig.app.json",
117
- "src/tsconfig.spec.json"
118
- ],
119
- "exclude": [
120
- "**/node_modules/**"
121
- ]
122
- }
123
- }
124
- }
125
- },
126
- "date-time-picker-app-e2e": {
127
- "root": "e2e/",
128
- "projectType": "application",
129
- "prefix": "",
130
- "architect": {
131
- "e2e": {
132
- "builder": "@angular-devkit/build-angular:protractor",
133
- "options": {
134
- "protractorConfig": "e2e/protractor.conf.js",
135
- "devServerTarget": "date-time-picker-app:serve"
136
- },
137
- "configurations": {
138
- "production": {
139
- "devServerTarget": "date-time-picker-app:serve:production"
140
- }
141
- }
142
- },
143
- "lint": {
144
- "builder": "@angular-devkit/build-angular:tslint",
145
- "options": {
146
- "tsConfig": "e2e/tsconfig.e2e.json",
147
- "exclude": [
148
- "**/node_modules/**"
149
- ]
150
- }
151
- }
152
- }
153
- },
154
- "picker": {
155
- "root": "projects/picker",
156
- "sourceRoot": "projects/picker/src",
157
- "projectType": "library",
158
- "prefix": "owl",
159
- "architect": {
160
- "build": {
161
- "builder": "@angular-devkit/build-angular:ng-packagr",
162
- "options": {
163
- "tsConfig": "projects/picker/tsconfig.lib.json",
164
- "project": "projects/picker/ng-package.json"
165
- },
166
- "configurations": {
167
- "production": {
168
- "tsConfig": "projects/picker/tsconfig.lib.prod.json"
169
- }
170
- }
171
- },
172
- "test": {
173
- "builder": "@angular-devkit/build-angular:karma",
174
- "options": {
175
- "main": "projects/picker/src/test.ts",
176
- "tsConfig": "projects/picker/tsconfig.spec.json",
177
- "karmaConfig": "projects/picker/karma.conf.js"
178
- }
179
- },
180
- "lint": {
181
- "builder": "@angular-devkit/build-angular:tslint",
182
- "options": {
183
- "tsConfig": [
184
- "projects/picker/tsconfig.lib.json",
185
- "projects/picker/tsconfig.spec.json"
186
- ],
187
- "exclude": [
188
- "**/node_modules/**"
189
- ]
190
- }
191
- }
192
- }
193
- }
194
- },
195
- "schematics": {
196
- "@schematics/angular:component": {
197
- "type": "component"
198
- },
199
- "@schematics/angular:directive": {
200
- "type": "directive"
201
- },
202
- "@schematics/angular:service": {
203
- "type": "service"
204
- },
205
- "@schematics/angular:guard": {
206
- "typeSeparator": "."
207
- },
208
- "@schematics/angular:interceptor": {
209
- "typeSeparator": "."
210
- },
211
- "@schematics/angular:module": {
212
- "typeSeparator": "."
213
- },
214
- "@schematics/angular:pipe": {
215
- "typeSeparator": "."
216
- },
217
- "@schematics/angular:resolver": {
218
- "typeSeparator": "."
219
- }
220
- }
221
- }
@@ -1,28 +0,0 @@
1
- // Protractor configuration file, see link for more information
2
- // https://github.com/angular/protractor/blob/master/lib/config.ts
3
-
4
- const { SpecReporter } = require('jasmine-spec-reporter');
5
-
6
- exports.config = {
7
- allScriptsTimeout: 11000,
8
- specs: [
9
- './src/**/*.e2e-spec.ts'
10
- ],
11
- capabilities: {
12
- 'browserName': 'chrome'
13
- },
14
- directConnect: true,
15
- baseUrl: 'http://localhost:4200/',
16
- framework: 'jasmine',
17
- jasmineNodeOpts: {
18
- showColors: true,
19
- defaultTimeoutInterval: 30000,
20
- print: function() {}
21
- },
22
- onPrepare() {
23
- require('ts-node').register({
24
- project: require('path').join(__dirname, './tsconfig.e2e.json')
25
- });
26
- jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27
- }
28
- };
@@ -1,14 +0,0 @@
1
- import { AppPage } from './app.po';
2
-
3
- describe('workspace-project App', () => {
4
- let page: AppPage;
5
-
6
- beforeEach(() => {
7
- page = new AppPage();
8
- });
9
-
10
- it('should display welcome message', () => {
11
- page.navigateTo();
12
- expect(page.getParagraphText()).toEqual('Welcome to date-time-picker-app!');
13
- });
14
- });
package/e2e/src/app.po.ts DELETED
@@ -1,11 +0,0 @@
1
- import { browser, by, element } from 'protractor';
2
-
3
- export class AppPage {
4
- navigateTo() {
5
- return browser.get('/');
6
- }
7
-
8
- getParagraphText() {
9
- return element(by.css('app-root h1')).getText();
10
- }
11
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "../out-tsc/app",
5
- "module": "commonjs",
6
- "target": "es5",
7
- "types": [
8
- "jasmine",
9
- "jasminewd2",
10
- "node"
11
- ]
12
- }
13
- }
@@ -1,62 +0,0 @@
1
- // Karma configuration file, see link for more information
2
- // https://karma-runner.github.io/1.0/config/configuration-file.html
3
-
4
- module.exports = function (config) {
5
- config.set({
6
- basePath: '',
7
- frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
- plugins: [
9
- require('karma-jasmine'),
10
- require('karma-chrome-launcher'),
11
- require('karma-jasmine-html-reporter'),
12
- require('karma-coverage'),
13
- require('@angular-devkit/build-angular/plugins/karma')
14
- ],
15
- client: {
16
- clearContext: false // leave Jasmine Spec Runner output visible in browser
17
- },
18
- coverageIstanbulReporter: {
19
- dir: require('path').join(__dirname, '../../coverage'),
20
- reports: ['html', 'lcovonly', 'json'],
21
- fixWebpackSourcePaths: true
22
- },
23
- customLaunchers: {
24
- ChromeHeadlessNoSandbox: {
25
- base: 'ChromeHeadless',
26
- flags: [
27
- '--no-sandbox',
28
- '--disable-web-security',
29
- '--disable-gpu',
30
- '--disable-dev-shm-usage',
31
- '--disable-extensions',
32
- '--remote-debugging-port=9222',
33
- '--headless'
34
- ]
35
- },
36
- ChromeHeadlessCI: {
37
- base: 'ChromeHeadless',
38
- flags: [
39
- '--no-sandbox',
40
- '--disable-web-security',
41
- '--disable-gpu',
42
- '--disable-dev-shm-usage',
43
- '--disable-extensions',
44
- '--disable-background-timer-throttling',
45
- '--disable-backgrounding-occluded-windows',
46
- '--disable-renderer-backgrounding',
47
- '--remote-debugging-port=9222',
48
- '--headless'
49
- ]
50
- }
51
- },
52
- reporters: ['progress', 'kjhtml'],
53
- port: 9876,
54
- colors: true,
55
- logLevel: config.LOG_INFO,
56
- autoWatch: true,
57
- // Use different browsers based on environment
58
- browsers: process.env.CI ? ['ChromeHeadlessCI'] : ['Chrome'],
59
- singleRun: process.env.CI ? true : false,
60
- restartOnFileChange: false
61
- });
62
- };
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/picker",
4
- "lib": {
5
- "entryFile": "src/public_api.ts"
6
- }
7
- }
@@ -1,28 +0,0 @@
1
- {
2
- "name": "@imihai/angular-datetime-picker",
3
- "version": "21.0.0",
4
- "description": "Angular Date Time Picker",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/danielmoncada/date-time-picker.git"
9
- },
10
- "homepage": "https://github.com/danielmoncada/date-time-picker",
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "peerDependencies": {
15
- "@angular/common": "^21.0.0",
16
- "@angular/core": "^21.0.0",
17
- "@angular/cdk": "^21.0.0",
18
- "luxon": "^3.7.2"
19
- },
20
- "dependencies": {
21
- "tslib": "^2.6.2"
22
- },
23
- "exports": {
24
- "./assets/style/picker.min.css": {
25
- "default": "./assets/style/picker.min.css"
26
- }
27
- }
28
- }
@@ -1,313 +0,0 @@
1
- /**
2
- * date-time-adapter.class
3
- */
4
- import { Observable, Subject } from 'rxjs';
5
- import { inject, InjectionToken, LOCALE_ID } from '@angular/core';
6
-
7
- /** InjectionToken for date time picker that can be used to override default locale code. */
8
- export const OWL_DATE_TIME_LOCALE = new InjectionToken<string>(
9
- 'OWL_DATE_TIME_LOCALE',
10
- {
11
- providedIn: 'root',
12
- factory: OWL_DATE_TIME_LOCALE_FACTORY
13
- }
14
- );
15
-
16
- /** @docs-private */
17
- export function OWL_DATE_TIME_LOCALE_FACTORY(): string {
18
- return inject(LOCALE_ID);
19
- }
20
-
21
- /** Provider for OWL_DATE_TIME_LOCALE injection token. */
22
- export const OWL_DATE_TIME_LOCALE_PROVIDER = {
23
- provide: OWL_DATE_TIME_LOCALE,
24
- useExisting: LOCALE_ID
25
- };
26
-
27
- export abstract class DateTimeAdapter<T> {
28
- /** The locale to use for all dates. */
29
- protected locale: any;
30
-
31
- /** A stream that emits when the locale changes. */
32
- protected _localeChanges = new Subject<string>();
33
- get localeChanges(): Observable<string> {
34
- return this._localeChanges;
35
- }
36
-
37
- public firstMonthOfTheYear: number = 0;
38
- public firstDayOfTheWeek: number = 0;
39
-
40
- /** total milliseconds in a day. */
41
- protected readonly millisecondsInDay = 86400000;
42
-
43
- /** total milliseconds in a minute. */
44
- protected readonly millisecondsInMinute = 60000;
45
-
46
- /**
47
- * Get the year of the given date
48
- */
49
- abstract getYear(date: T): number;
50
-
51
- /**
52
- * Get the month of the given date
53
- * 0 -- January
54
- * 11 -- December
55
- * */
56
- abstract getMonth(date: T): number;
57
-
58
- /**
59
- * Get the day of the week of the given date
60
- * 0 -- Sunday
61
- * 6 -- Saturday
62
- * */
63
- abstract getDay(date: T): number;
64
-
65
- /**
66
- * Get the day num of the given date
67
- */
68
- abstract getDate(date: T): number;
69
-
70
- /**
71
- * Get the hours of the given date
72
- */
73
- abstract getHours(date: T): number;
74
-
75
- /**
76
- * Get the minutes of the given date
77
- */
78
- abstract getMinutes(date: T): number;
79
-
80
- /**
81
- * Get the seconds of the given date
82
- */
83
- abstract getSeconds(date: T): number;
84
-
85
- /**
86
- * Get the milliseconds timestamp of the given date
87
- */
88
- abstract getTime(date: T): number;
89
-
90
- /**
91
- * Gets the number of days in the month of the given date.
92
- */
93
- abstract getNumDaysInMonth(date: T): number;
94
-
95
- /**
96
- * Get the number of calendar days between the given dates.
97
- * If dateLeft is before dateRight, it would return positive value
98
- * If dateLeft is after dateRight, it would return negative value
99
- */
100
- abstract differenceInCalendarDays(dateLeft: T, dateRight: T): number;
101
-
102
- /**
103
- * Gets the name for the year of the given date.
104
- */
105
- abstract getYearName(date: T): string;
106
-
107
- /**
108
- * Get a list of month names
109
- */
110
- abstract getMonthNames(style: 'long' | 'short' | 'narrow'): string[];
111
-
112
- /**
113
- * Get a list of week names
114
- */
115
- abstract getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[];
116
-
117
- /**
118
- * Gets a list of names for the dates of the month.
119
- */
120
- abstract getDateNames(): string[];
121
-
122
- /**
123
- * Return a Date object as a string, using the ISO standard
124
- */
125
- abstract toIso8601(date: T): string;
126
-
127
- /**
128
- * Check if the give dates are equal
129
- */
130
- abstract isEqual(dateLeft: T, dateRight: T): boolean;
131
-
132
- /**
133
- * Check if the give dates are the same day
134
- */
135
- abstract isSameDay(dateLeft: T, dateRight: T): boolean;
136
-
137
- /**
138
- * Checks whether the given date is valid.
139
- */
140
- abstract isValid(date: T): boolean;
141
-
142
- /**
143
- * Gets date instance that is not valid.
144
- */
145
- abstract invalid(): T;
146
-
147
- /**
148
- * Checks whether the given object is considered a date instance by this DateTimeAdapter.
149
- */
150
- abstract isDateInstance(obj: any): boolean;
151
-
152
- /**
153
- * Add the specified number of years to the given date
154
- */
155
- abstract addCalendarYears(date: T, amount: number): T;
156
-
157
- /**
158
- * Add the specified number of months to the given date
159
- */
160
- abstract addCalendarMonths(date: T, amount: number): T;
161
-
162
- /**
163
- * Add the specified number of days to the given date
164
- */
165
- abstract addCalendarDays(date: T, amount: number): T;
166
-
167
- /**
168
- * Set the hours to the given date.
169
- */
170
- abstract setHours(date: T, amount: number): T;
171
-
172
- /**
173
- * Set the minutes to the given date.
174
- */
175
- abstract setMinutes(date: T, amount: number): T;
176
-
177
- /**
178
- * Set the seconds to the given date.
179
- */
180
- abstract setSeconds(date: T, amount: number): T;
181
-
182
- /**
183
- * Creates a date with the given year, month, date, hour, minute and second. Does not allow over/under-flow of the
184
- * month and date.
185
- */
186
- abstract createDate(year: number, month: number, date: number): T;
187
- abstract createDate(
188
- year: number,
189
- month: number,
190
- date: number,
191
- hours: number,
192
- minutes: number,
193
- seconds: number
194
- ): T;
195
-
196
- /**
197
- * Clone the given date
198
- */
199
- abstract clone(date: T): T;
200
-
201
- /**
202
- * Get a new moment
203
- * */
204
- abstract now(): T;
205
-
206
- /**
207
- * Formats a date as a string according to the given format.
208
- */
209
- abstract format(date: T, displayFormat: any): string;
210
-
211
- /**
212
- * Parse a user-provided value to a Date Object
213
- */
214
- abstract parse(value: any, parseFormat: any): T | null;
215
-
216
- /**
217
- * Compare two given dates
218
- * 1 if the first date is after the second,
219
- * -1 if the first date is before the second
220
- * 0 if dates are equal.
221
- * */
222
- compare(first: T, second: T): number {
223
- if (!this.isValid(first) || !this.isValid(second)) {
224
- throw Error('JSNativeDate: Cannot compare invalid dates.');
225
- }
226
-
227
- const dateFirst = this.clone(first);
228
- const dateSecond = this.clone(second);
229
-
230
- const diff = this.getTime(dateFirst) - this.getTime(dateSecond);
231
-
232
- if (diff < 0) {
233
- return -1;
234
- } else if (diff > 0) {
235
- return 1;
236
- } else {
237
- // Return 0 if diff is 0; return NaN if diff is NaN
238
- return diff;
239
- }
240
- }
241
-
242
- /**
243
- * Check if two given dates are in the same year
244
- * 1 if the first date's year is after the second,
245
- * -1 if the first date's year is before the second
246
- * 0 if two given dates are in the same year
247
- * */
248
- compareYear(first: T, second: T): number {
249
- if (!this.isValid(first) || !this.isValid(second)) {
250
- throw Error('JSNativeDate: Cannot compare invalid dates.');
251
- }
252
-
253
- const yearLeft = this.getYear(first);
254
- const yearRight = this.getYear(second);
255
-
256
- const diff = yearLeft - yearRight;
257
-
258
- if (diff < 0) {
259
- return -1;
260
- } else if (diff > 0) {
261
- return 1;
262
- } else {
263
- return 0;
264
- }
265
- }
266
-
267
- /**
268
- * Attempts to deserialize a value to a valid date object. This is different from parsing in that
269
- * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
270
- * string). The default implementation does not allow any deserialization, it simply checks that
271
- * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
272
- * method on all of it's `@Input()` properties that accept dates. It is therefore possible to
273
- * support passing values from your backend directly to these properties by overriding this method
274
- * to also deserialize the format used by your backend.
275
- */
276
- deserialize(value: any): T | null {
277
- if (
278
- value == null ||
279
- (this.isDateInstance(value) && this.isValid(value))
280
- ) {
281
- return value;
282
- }
283
- return this.invalid();
284
- }
285
-
286
- /**
287
- * Sets the locale used for all dates.
288
- */
289
- setLocale(locale: string) {
290
- this.locale = locale;
291
- this._localeChanges.next(locale);
292
- }
293
-
294
- /**
295
- * Get the locale used for all dates.
296
- * */
297
- getLocale() {
298
- return this.locale;
299
- }
300
-
301
- /**
302
- * Clamp the given date between min and max dates.
303
- */
304
- clampDate(date: T, min?: T | null, max?: T | null): T {
305
- if (min && this.compare(date, min) < 0) {
306
- return min;
307
- }
308
- if (max && this.compare(date, max) > 0) {
309
- return max;
310
- }
311
- return date;
312
- }
313
- }