MOBILE-3320 calendar: Fix date pickers
This commit is contained in:
		
							parent
							
								
									ce451e9a1d
								
							
						
					
					
						commit
						029e24e5cb
					
				| @ -450,8 +450,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { | ||||
|     async submit(): Promise<void> { | ||||
|         // Validate data.
 | ||||
|         const formData = this.form.value; | ||||
|         const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart); | ||||
|         const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil); | ||||
|         const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart, true); | ||||
|         const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil, true); | ||||
|         const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10); | ||||
|         let error: string | undefined; | ||||
| 
 | ||||
|  | ||||
| @ -328,15 +328,23 @@ export class CoreTimeUtilsProvider { | ||||
|     /** | ||||
|      * Convert a text into user timezone timestamp. | ||||
|      * | ||||
|      * @todo The `applyOffset` argument is only used as a workaround, it should be removed once | ||||
|      * MOBILE-3784 is resolved. | ||||
|      * | ||||
|      * @param date To convert to timestamp. | ||||
|      * @param applyOffset Whether to apply offset to date or not. | ||||
|      * @return Converted timestamp. | ||||
|      */ | ||||
|     convertToTimestamp(date: string): number { | ||||
|         if (typeof date == 'string' && date.slice(-1) == 'Z') { | ||||
|             return moment(date).unix() - (moment().utcOffset() * 60); | ||||
|     convertToTimestamp(date: string, applyOffset?: boolean): number { | ||||
|         const timestamp = moment(date).unix(); | ||||
| 
 | ||||
|         if (typeof applyOffset !== 'undefined') { | ||||
|             return applyOffset ? timestamp - moment().utcOffset() * 60 : timestamp; | ||||
|         } | ||||
| 
 | ||||
|         return moment(date).unix(); | ||||
|         return typeof date == 'string' && date.slice(-1) == 'Z' | ||||
|             ? timestamp - moment().utcOffset() * 60 | ||||
|             : timestamp; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user