uiDateTimePicker Add comments
This commit is contained in:
parent
266c633972
commit
9aba97714d
|
@ -87,6 +87,8 @@ void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
|
|||
date = [d->dp dateValue];
|
||||
t = (time_t) [date timeIntervalSince1970];
|
||||
|
||||
// Copy time to minimize a race condition
|
||||
// time.h functions use global non-thread-safe data
|
||||
tmbuf = *localtime(&t);
|
||||
memcpy(time, &tmbuf, sizeof(struct tm));
|
||||
}
|
||||
|
@ -96,6 +98,7 @@ void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
|
|||
time_t t;
|
||||
struct tm tmbuf;
|
||||
|
||||
// Copy time because mktime() modifies its argument
|
||||
memcpy(&tmbuf, time, sizeof(struct tm));
|
||||
t = mktime(&tmbuf);
|
||||
|
||||
|
|
1
ui.h
1
ui.h
|
@ -251,6 +251,7 @@ _UI_EXTERN uiRadioButtons *uiNewRadioButtons(void);
|
|||
struct tm;
|
||||
typedef struct uiDateTimePicker uiDateTimePicker;
|
||||
#define uiDateTimePicker(this) ((uiDateTimePicker *) (this))
|
||||
// TODO document that tm_wday and tm_yday are undefined, and tm_isdst should be -1
|
||||
_UI_EXTERN void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time);
|
||||
_UI_EXTERN void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time);
|
||||
_UI_EXTERN void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data);
|
||||
|
|
|
@ -576,6 +576,8 @@ void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
|
|||
t = g_date_time_to_unix(dt);
|
||||
g_date_time_unref(dt);
|
||||
|
||||
// Copy time to minimize a race condition
|
||||
// time.h functions use global non-thread-safe data
|
||||
tmbuf = *localtime(&t);
|
||||
memcpy(time, &tmbuf, sizeof(struct tm));
|
||||
}
|
||||
|
@ -585,6 +587,7 @@ void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
|
|||
time_t t;
|
||||
struct tm tmbuf;
|
||||
|
||||
// Copy time because mktime() modifies its argument
|
||||
memcpy(&tmbuf, time, sizeof(struct tm));
|
||||
t = mktime(&tmbuf);
|
||||
|
||||
|
|
Loading…
Reference in New Issue