Skip to content

Commit 73979e1

Browse files
authored
Bugfixes (#345)
* issue341: ! fix error cannot read property 'replace' of null on 24 Hrs format * issue342: ! fix issue with displaying time `24:xx` instead of `00:xx` with default locale * * update version and CHANGELOG.md * * update luxon version * * remove NumberingSystem import * * change builder version
1 parent 71406f6 commit 73979e1

File tree

7 files changed

+410
-234
lines changed

7 files changed

+410
-234
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file
44

5+
## 5.5.3 (2020-05-28)
6+
7+
### Fixes
8+
9+
* fix(ngx-material-timepicker): fix error cannot read property 'replace' of null on 24 Hrs format,
10+
fixes [(#341)](https://github.com/Agranom/ngx-material-timepicker/issues/341)
11+
* fix(ngx-material-timepicker): fix issue with displaying time `24:xx` instead of `00:xx` with default locale,
12+
fixes [(#342)](https://github.com/Agranom/ngx-material-timepicker/issues/342)
13+
514
## 5.5.2 (2020-05-11)
615

716
### Fixes

package-lock.json

Lines changed: 383 additions & 217 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ngx-material-timepicker",
33
"description": "Handy material design timepicker for angular",
4-
"version": "5.5.2",
4+
"version": "5.5.3",
55
"license": "MIT",
66
"author": "Vitalii Boiko <boyko330@gmail.com>",
77
"keywords": [
@@ -42,8 +42,8 @@
4242
"types": ".src/app/material-timepicker/index.d.ts",
4343
"private": false,
4444
"dependencies": {
45-
"@types/luxon": "^1.11.1",
46-
"luxon": "^1.22.0"
45+
"@types/luxon": "1.11.1",
46+
"luxon": "1.24.0"
4747
},
4848
"devDependencies": {
4949
"@angular-devkit/build-angular": "^0.800.3",
@@ -77,7 +77,7 @@
7777
"karma-jasmine": "~1.1.0",
7878
"karma-jasmine-html-reporter": "^0.2.2",
7979
"ng-packagr": "^5.2.0",
80-
"node-sass": "^4.13.1",
80+
"node-sass": "^4.14.1",
8181
"npm-run-all": "^4.1.3",
8282
"protractor": "^5.4.2",
8383
"rxjs": "^6.5.2",

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ <h3 class="ngx-material-timepicker-examples__title">Examples</h3>
278278
</main>
279279
<footer class="footer">
280280
<div class="container">
281-
<p class="footer__version">Current version 5.5.2</p>
281+
<p class="footer__version">Current version 5.5.3</p>
282282
</div>
283283
</footer>
284284
</div>

src/app/material-timepicker/directives/ngx-timepicker.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class TimepickerDirective implements ControlValueAccessor, OnDestroy, OnC
186186
this.value = time;
187187
this.onChange(this.value);
188188
this.onTouched();
189-
this.defaultTime = this.value;
189+
this.defaultTime = this._value;
190190
}));
191191
} else {
192192
throw new Error('NgxMaterialTimepickerComponent is not defined.' +

src/app/material-timepicker/pipes/time-parser.pipe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Inject, Injectable, Pipe, PipeTransform } from '@angular/core';
22
import { TIME_LOCALE } from '../tokens/time-locale.token';
33
import { TimeUnit } from '../models/time-unit.enum';
4-
import { DateTime, NumberingSystem } from 'luxon';
4+
import { DateTime } from 'luxon';
55

66
type TimeMeasure = 'hour' | 'minute';
77

@@ -11,10 +11,10 @@ type TimeMeasure = 'hour' | 'minute';
1111
@Injectable()
1212
export class TimeParserPipe implements PipeTransform {
1313

14-
private readonly numberingSystem: NumberingSystem;
14+
private readonly numberingSystem: string;
1515

1616
constructor(@Inject(TIME_LOCALE) private locale: string) {
17-
this.numberingSystem = DateTime.local().setLocale(this.locale).resolvedLocaleOpts().numberingSystem as NumberingSystem;
17+
this.numberingSystem = DateTime.local().setLocale(this.locale).resolvedLocaleOpts().numberingSystem;
1818
}
1919

2020
transform(time: string | number, timeUnit = TimeUnit.HOUR): number | string {

src/app/material-timepicker/services/time-adapter.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {DateTime, DateTimeFormatOptions, LocaleOptions, NumberingSystem} from 'luxon';
1+
import { DateTime, LocaleOptions } from 'luxon';
22

3-
import {TimeFormat} from '../models/time-format.enum';
4-
import {TimePeriod} from '../models/time-period.enum';
5-
import {isBetween, isSameOrAfter, isSameOrBefore} from '../utils/timepicker.utils';
6-
import {TimeOptions} from '../models/time-options.interface';
3+
import { TimeFormat } from '../models/time-format.enum';
4+
import { TimePeriod } from '../models/time-period.enum';
5+
import { isBetween, isSameOrAfter, isSameOrBefore } from '../utils/timepicker.utils';
6+
import { TimeOptions } from '../models/time-options.interface';
77

88
// @dynamic
99
export class TimeAdapter {
1010
static DEFAULT_FORMAT = 12;
1111
static DEFAULT_LOCALE = 'en-US';
12-
static DEFAULT_NUMBERING_SYSTEM: NumberingSystem = 'latn';
12+
static DEFAULT_NUMBERING_SYSTEM = 'latn';
1313

1414
static parseTime(time: string, opts: TimeOptions): DateTime {
1515
const {numberingSystem, locale} = TimeAdapter.getLocaleOptionsByTime(time, opts);
@@ -42,7 +42,8 @@ export class TimeAdapter {
4242

4343
static toLocaleTimeString(time: string, opts: TimeOptions = {}): string {
4444
const {format = TimeAdapter.DEFAULT_FORMAT, locale = TimeAdapter.DEFAULT_LOCALE} = opts;
45-
const timeFormat: DateTimeFormatOptions = {...DateTime.TIME_SIMPLE, hour12: format !== 24};
45+
const hourCycle = format === 24 ? 'h23' : 'h12';
46+
const timeFormat = {...DateTime.TIME_SIMPLE, hourCycle};
4647
const timeMask = (format === 24) ? TimeFormat.TWENTY_FOUR_SHORT : TimeFormat.TWELVE_SHORT;
4748

4849
return DateTime.fromFormat(time, timeMask).setLocale(locale).toLocaleString(timeFormat);
@@ -105,7 +106,7 @@ export class TimeAdapter {
105106

106107
private static getLocaleOptionsByTime(time: string, opts: TimeOptions): LocaleOptions {
107108
const {numberingSystem, locale} = DateTime.local().setLocale(opts.locale).resolvedLocaleOpts();
108-
const localeConfig: LocaleOptions = {numberingSystem: numberingSystem as NumberingSystem, locale};
109+
const localeConfig: LocaleOptions = {numberingSystem: numberingSystem, locale};
109110
const defaultConfig: LocaleOptions = {numberingSystem: TimeAdapter.DEFAULT_NUMBERING_SYSTEM, locale: TimeAdapter.DEFAULT_LOCALE};
110111

111112
return isNaN(parseInt(time, 10)) ? localeConfig : defaultConfig;

0 commit comments

Comments
 (0)