MOBILE-2808 datetime: Do not use am/pm in datetime
parent
b0477ab1d3
commit
11f34887d0
|
@ -72,9 +72,9 @@ export class AddonCalendarEventPage {
|
||||||
this.defaultTime = defaultTime * 60;
|
this.defaultTime = defaultTime * 60;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
|
// Calculate format to use.
|
||||||
this.notificationFormat = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedatetime'))
|
this.notificationFormat = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment(
|
||||||
.replace(/[\[\]]/g, '');
|
this.translate.instant('core.strftimedatetime')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo
|
||||||
|
|
||||||
let val;
|
let val;
|
||||||
|
|
||||||
// Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
|
// Calculate format to use.
|
||||||
this.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedate'))
|
this.format = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment(
|
||||||
.replace(/[\[\]]/g, '');
|
this.translate.instant('core.strftimedate')));
|
||||||
|
|
||||||
if (this.mode == 'search') {
|
if (this.mode == 'search') {
|
||||||
this.addControl('f_' + this.field.id + '_z');
|
this.addControl('f_' + this.field.id + '_z');
|
||||||
|
|
|
@ -47,9 +47,9 @@ export class AddonUserProfileFieldDatetimeComponent implements OnInit {
|
||||||
// Check if it's only date or it has time too.
|
// Check if it's only date or it has time too.
|
||||||
const hasTime = this.utils.isTrueOrOne(field.param3);
|
const hasTime = this.utils.isTrueOrOne(field.param3);
|
||||||
|
|
||||||
// Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
|
// Calculate format to use.
|
||||||
field.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.' +
|
field.format = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment(
|
||||||
(hasTime ? 'strftimedatetime' : 'strftimedate'))).replace(/[\[\]]/g, '');
|
this.translate.instant('core.' + (hasTime ? 'strftimedatetime' : 'strftimedate'))));
|
||||||
|
|
||||||
// Check min value.
|
// Check min value.
|
||||||
if (field.param1) {
|
if (field.param1) {
|
||||||
|
|
|
@ -118,6 +118,29 @@ export class CoreTimeUtilsProvider {
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix format to use in an ion-datetime.
|
||||||
|
*
|
||||||
|
* @param {string} format Format to use.
|
||||||
|
* @return {string} Fixed format.
|
||||||
|
*/
|
||||||
|
fixFormatForDatetime(format: string): string {
|
||||||
|
if (!format) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// The component ion-datetime doesn't support escaping characters ([]), so we remove them.
|
||||||
|
let fixed = format.replace(/[\[\]]/g, '');
|
||||||
|
|
||||||
|
if (fixed.indexOf('A') != -1) {
|
||||||
|
// Do not use am/pm format because there is a bug in ion-datetime.
|
||||||
|
fixed = fixed.replace(/ ?A/g, '');
|
||||||
|
fixed = fixed.replace(/h/g, 'H');
|
||||||
|
}
|
||||||
|
|
||||||
|
return fixed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns hours, minutes and seconds in a human readable format
|
* Returns hours, minutes and seconds in a human readable format
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue