Skip to content

Commit 0d53aea

Browse files
committed
Updated optional iOS native date/time input method.
1 parent fa9c01c commit 0d53aea

6 files changed

Lines changed: 46 additions & 27 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svc-ng",
3-
"version": "1.8.2",
3+
"version": "1.8.3",
44
"license": "MIT AND GPL-3.0-or-later",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"scripts": {

src/app/svc/svc-date-editor.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export class SvcDateEditorComponent extends KsSequenceEditorComponent implements
184184
else
185185
i[0].value = NO_BREAK_SPACE;
186186

187+
// noinspection JSSuspiciousNameCombination
187188
const y4 = M_.div_tt0(y, 1000);
188189
const y3 = M_.div_tt0(y - y4 * 1000, 100);
189190
const y2 = M_.div_tt0(y - y4 * 1000 - y3 * 100, 10);

src/app/svc/svc-native-date-time-dialog/svc-native-date-time-dialog.component.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@
77
<p-radioButton name="native-date-time-1" [value]="true" [(ngModel)]="nativeDateTime" label="Use your web browser's own date/time input method"></p-radioButton>
88
<div class="explanation">
99
This provides greater ease of use with mobile devices, but can't be used to enter dates before the year 1 CE.
10-
<ng-container *ngIf="isIOS">
11-
<p>
12-
For iOS devices, there is no native date/time input that covers the full range of time from years down to minutes.
13-
When using the web browser's input method, touch the left side of the clock to set year, month and date. Touch the
14-
right side to enter month, date, hour and minute.
15-
</p>
16-
<p>
17-
When setting years a century or more ago there might be a discrepancy of a few minutes between the time shown in
18-
the native date/time input and the time shown by the Sky View Café clock.
19-
</p>
20-
</ng-container>
10+
<p *ngIf="isIOS">
11+
For iOS devices, there is no native date/time input that covers the full range of time from years down to minutes.
12+
When using the web browser's input method, touch the left side of the clock to set year, month and date. Touch the
13+
right side to enter hour and minute.
14+
</p>
2115
</div>
2216
This setting can be changed later using the <strong>More.../Preferences</strong> dialog
2317

src/app/svc/svc-native-date-time-dialog/svc-native-date-time-dialog.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class SvcNativeDateTimeDialogComponent {
4444
nativeDateTime = this.app.nativeDateTime;
4545
// noinspection JSMethodCanBeStatic
4646
get isIOS(): boolean { return isIOS(); }
47-
get dialogSize(): string { return isIOS() ? '500!,458' : '500!,300'; }
47+
get dialogSize(): string { return isIOS() ? '500!,400' : '500!,300'; }
4848

4949
constructor(private app: AppService) { }
5050

src/app/svc/svc-time-editor/svc-time-editor.component.ts

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const platformNativeDateTime = (isIOS() || isAndroid() && isChrome());
3939
const NO_BREAK_SPACE = '\u00A0';
4040
const THREE_PER_EM_SPACE = '\u2004';
4141

42+
type TimeFormat = 'date' | 'time' | 'datetime-local';
43+
4244
@Component({
4345
selector: 'svc-time-editor',
4446
animations: [BACKGROUND_ANIMATIONS],
@@ -64,7 +66,7 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
6466
@ViewChild('localTime', { static: true }) private localTimeRef: ElementRef;
6567
private localTime: HTMLInputElement;
6668

67-
localTimeFormat: 'date' | 'datetime-local' = 'datetime-local';
69+
localTimeFormat: TimeFormat = 'datetime-local';
6870
localTimeMin: string;
6971
localTimeMax: string;
7072

@@ -94,17 +96,23 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
9496
let newTime: number;
9597

9698
if (newValue) {
97-
const match = /(\d\d\d\d)-(\d\d)-(\d\d)(?:T(\d\d):(\d\d))?/.exec(newValue);
99+
const w = this.dateTime.wallTime;
100+
let $;
98101

99-
if (match) {
100-
const d = match.slice(1).map(n => Number(n));
102+
if (($ = /(\d\d\d\d)-(\d\d)-(\d\d)(?:T(\d\d):(\d\d))?/.exec(newValue))) {
103+
const d = $.slice(1).map(n => Number(n));
101104

102-
if (isNil(match[4])) {
103-
d[3] = this.dateTime.wallTime.hrs;
104-
d[4] = this.dateTime.wallTime.min;
105+
if (isNil($[4])) {
106+
d[3] = w.hrs;
107+
d[4] = w.min;
105108
}
106109

107-
newTime = new KsDateTime({y: d[0], m: d[1], d: d[2], hrs: d[3], min: d[4], sec: 0}, this.timeZone, this._gregorianChangeDate).utcTimeMillis;
110+
newTime = new KsDateTime({ y: d[0], m: d[1], d: d[2], hrs: d[3], min: d[4], sec: 0 }, this.timeZone, this._gregorianChangeDate).utcTimeMillis;
111+
}
112+
else if (($ = /(\d\d):(\d\d)/.exec(newValue))) {
113+
const t = $.slice(1).map(n => Number(n));
114+
115+
newTime = new KsDateTime({ y: w.y, m: w.m, d: w.d, hrs: t[0], min: t[1], sec: 0 }, this.timeZone, this._gregorianChangeDate).utcTimeMillis;
108116
}
109117
}
110118
else
@@ -183,8 +191,13 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
183191
}
184192

185193
protected onTouchStartAlternate(event: TouchEvent): void {
186-
const selection = this.getSelectionForTouchEvent(event);
187-
const format = (isIOS() && 0 <= selection && selection < 11 ? 'date' : 'datetime-local');
194+
let format: TimeFormat = 'datetime-local';
195+
196+
if (isIOS()) {
197+
const selection = this.getSelectionForTouchEvent(event);
198+
199+
format = (0 <= selection && selection < 11 ? 'date' : 'time');
200+
}
188201

189202
if (this.localTimeFormat !== format) {
190203
// Changing the format of the input (using the "type" attribute) sets off a number of updates
@@ -235,7 +248,10 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
235248
}
236249

237250
private adjustLocalTimeMin(): void {
238-
this.localTimeMin = padLeft(max(this._minYear, 1), 4, '0') + '-01-01' + (this.localTimeFormat === 'date' ? '' : 'T00:00');
251+
if (this.localTimeFormat === 'time')
252+
this.localTimeMin = null;
253+
else
254+
this.localTimeMin = padLeft(max(this._minYear, 1), 4, '0') + '-01-01' + (this.localTimeFormat === 'date' ? '' : 'T00:00');
239255
}
240256

241257
get maxYear(): number { return this._maxYear; }
@@ -247,7 +263,10 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
247263
}
248264

249265
private adjustLocalTimeMax(): void {
250-
this.localTimeMax = padLeft(this._maxYear, 4, '0') + '-12-31' + (this.localTimeFormat === 'date' ? '' : 'T23:59');
266+
if (this.localTimeFormat === 'time')
267+
this.localTimeMax = null;
268+
else
269+
this.localTimeMax = padLeft(this._maxYear, 4, '0') + '-12-31' + (this.localTimeFormat === 'date' ? '' : 'T23:59');
251270
}
252271

253272
get timeZone(): KsTimeZone { return this.dateTime.timeZone; }
@@ -419,8 +438,11 @@ export class SvcTimeEditorComponent extends KsSequenceEditorComponent implements
419438
if (this.isNativeDateTimeActive() && year < 1)
420439
year = 1;
421440

422-
this._localTimeValue = `${padLeft(year, 4, '0')}-${padLeft(w.m, 2, '0')}-${padLeft(w.d, 2, '0')}` +
423-
(this.localTimeFormat === 'date' ? '' : `T${padLeft(w.hrs, 2, '0')}:${padLeft(w.min, 2, '0')}`);
441+
if (this.localTimeFormat === 'time')
442+
this._localTimeValue = `${padLeft(w.hrs, 2, '0')}:${padLeft(w.min, 2, '0')}`;
443+
else
444+
this._localTimeValue = `${padLeft(year, 4, '0')}-${padLeft(w.m, 2, '0')}-${padLeft(w.d, 2, '0')}` +
445+
(this.localTimeFormat === 'date' ? '' : `T${padLeft(w.hrs, 2, '0')}:${padLeft(w.min, 2, '0')}`);
424446
}
425447

426448
private getWallTimeFromDigits(): DateAndTime {

src/assets/about.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
<h2 class="header-sans"><a name="history">What's New / Version History</a></h2>
6161
<div style="padding-left: 1em; text-indent: -1em">
6262

63+
<p><b>1.8.3, 2019-07-10:</b> Updated optional iOS native date/time input method.</p>
64+
6365
<p><b>1.8.2, 2019-07-10:</b> Minor change to accommodate geographic search ratings higher than 9.</p>
6466

6567
<p><b>1.8.0, 1.8.1, 2019-07-07:</b> Add option (off by default) to use native iOS or Android touch interface for date/time

0 commit comments

Comments
 (0)