forked from EVOgeek/Vmeda.Online
		
	MOBILE-2808 datetime: Do not use am/pm in datetime
This commit is contained in:
		
							parent
							
								
									b0477ab1d3
								
							
						
					
					
						commit
						11f34887d0
					
				| @ -72,9 +72,9 @@ export class AddonCalendarEventPage { | ||||
|                 this.defaultTime = defaultTime * 60; | ||||
|             }); | ||||
| 
 | ||||
|         // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
 | ||||
|         this.notificationFormat = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedatetime')) | ||||
|             .replace(/[\[\]]/g, ''); | ||||
|             // Calculate format to use.
 | ||||
|             this.notificationFormat = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment( | ||||
|                     this.translate.instant('core.strftimedatetime'))); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -42,9 +42,9 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo | ||||
| 
 | ||||
|         let val; | ||||
| 
 | ||||
|         // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
 | ||||
|         this.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedate')) | ||||
|                 .replace(/[\[\]]/g, ''); | ||||
|         // Calculate format to use.
 | ||||
|         this.format = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment( | ||||
|                 this.translate.instant('core.strftimedate'))); | ||||
| 
 | ||||
|         if (this.mode == 'search') { | ||||
|             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.
 | ||||
|             const hasTime = this.utils.isTrueOrOne(field.param3); | ||||
| 
 | ||||
|             // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them.
 | ||||
|             field.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.' + | ||||
|                     (hasTime ? 'strftimedatetime' : 'strftimedate'))).replace(/[\[\]]/g, ''); | ||||
|             // Calculate format to use.
 | ||||
|             field.format = this.timeUtils.fixFormatForDatetime(this.timeUtils.convertPHPToMoment( | ||||
|                     this.translate.instant('core.' + (hasTime ? 'strftimedatetime' : 'strftimedate')))); | ||||
| 
 | ||||
|             // Check min value.
 | ||||
|             if (field.param1) { | ||||
|  | ||||
| @ -118,6 +118,29 @@ export class CoreTimeUtilsProvider { | ||||
|         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 | ||||
|      * | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user