From 8818d3418594e7a85034cba6cb91e2a6d844d03e Mon Sep 17 00:00:00 2001 From: Hannes Juutilainen Date: Wed, 20 Sep 2017 14:50:56 +0300 Subject: [PATCH] Explicitly set a default time zone to get force install after date to display correctly. GitHub #150. --- .../UI Controllers/MAAdvancedPackageEditor.m | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/MunkiAdmin/UI Controllers/MAAdvancedPackageEditor.m b/MunkiAdmin/UI Controllers/MAAdvancedPackageEditor.m index 356c222..1f9ef46 100644 --- a/MunkiAdmin/UI Controllers/MAAdvancedPackageEditor.m +++ b/MunkiAdmin/UI Controllers/MAAdvancedPackageEditor.m @@ -47,12 +47,7 @@ - (NSModalSession)beginEditSessionWithObject:(PackageMO *)aPackage delegate:(id) self.delegate = modalDelegate; [self.mainTabView selectTabViewItemAtIndex:0]; - // Set the force_install_after_date date picker to use UTC - NSTimeZone *timeZoneUTC = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; - NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; - [gregorian setTimeZone:timeZoneUTC]; - [self.forceInstallDatePicker setCalendar:gregorian]; - [self.forceInstallDatePicker setTimeZone:timeZoneUTC]; + [self updateDatePickerTimeZone]; [self setDefaultValuesFromPackage:self.pkginfoToEdit]; @@ -768,6 +763,17 @@ - (void)updateIconNameComboBoxAutoCompleteList self.iconNameSuggestions = newIconNameSuggestions; } +- (void)updateDatePickerTimeZone +{ + // Set the force_install_after_date date picker to use UTC (don't try to display it in some other time zone) + NSTimeZone *timeZoneUTC = [NSTimeZone timeZoneWithName:@"UTC"]; + [NSTimeZone setDefaultTimeZone:timeZoneUTC]; + NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + [gregorian setTimeZone:timeZoneUTC]; + [self.forceInstallDatePicker setCalendar:gregorian]; + [self.forceInstallDatePicker setTimeZone:timeZoneUTC]; +} + - (void)windowDidLoad { @@ -853,12 +859,7 @@ - (void)windowDidLoad [self updateIconNameComboBoxAutoCompleteList]; [self.iconNameComboBox setDelegate:self]; - // Set the force_install_after_date date picker to use UTC - NSTimeZone *timeZoneUTC = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; - NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; - [gregorian setTimeZone:timeZoneUTC]; - [self.forceInstallDatePicker setCalendar:gregorian]; - [self.forceInstallDatePicker setTimeZone:timeZoneUTC]; + [self updateDatePickerTimeZone]; [self setDefaultValuesFromPackage:self.pkginfoToEdit];