Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
- Subject: Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
- From: "Sean McBride" <email@hidden>
- Date: Wed, 6 Apr 2005 20:18:01 -0400
Simon Liu (email@hidden) on 2005-04-06 12:58 said:
>> IIRC, the time change notification is undocumented and you need to use
>> Carbon, but my code is at home and I'm at work...
>
>Do you mean AppleTimePreferencesChangedNotification ?
>http://www.cocoabuilder.com/archive/message/cocoa/2004/9/28/118450
No, that's to get notification that the user has changed the date
format... like from yyyy/mm/dd to mm/dd/yyyy or something.
Now I'm home so I checked my code, the thing I'm talking about is
"kEventSystemTimeDateChanged". Here is a snipit of my code:
- (void)registerDateChangeEvent
{
// Create and install a Carbon event handler that will notify us when
// the user changes the date from the System Preferences.
// There seems to be no Cocoa notification for this
EventTypeSpec eventType;
eventType.eventClass = kEventClassSystem;
eventType.eventKind = kEventSystemTimeDateChanged;
EventHandlerUPP eventHandlerUPP = NewEventHandlerUPP(DateChangeEventHandler);
EventHandlerRef eventHandlerRef = NULL;
(void)InstallApplicationEventHandler(
eventHandlerUPP, // inHandler
1, // inNumTypes
&eventType, // inList
self, // inUserData
&eventHandlerRef);
[self setDateChangeEventHandlerRef:eventHandlerRef];
}
- (void)unRegisterDateChangeEvent
{
(void)RemoveEventHandler ([self dateChangeEventHandlerRef]);
[self setDateChangeEventHandlerRef:NULL];
}
pascal OSStatus DateChangeEventHandler (
EventHandlerCallRef nextHandler,
EventRef switchEvent,
void* userData)
{
// do something
return noErr;
}
Mind you I'm not sure this Carbon event is sent in the case of DST
change... it is certainly sent if the user manually changes the clock.
You might ask on the carbon list or check its archives.
>> NSCalendarDate also has a time zone component, so it should be able to
>> represent both 01:30s.
>
>You're sort of right in that you can 'represent' the 01:30, but only
>in timeInterval form.
>The NSCalendarDate docs for +dateWithYear:... state the second 01:30
>can't be created:
Oh. :( Weird, considering the time zone can be specified. Sorry, I
dunno what to suggest.
--
"I object to violence because when it appears to do good, the good is
only temporary; the evil it does is permanent." - Gandhi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden