comparison src/c/urweb.c @ 1982:2b95ecdd94eb

Use localtime, not gmtime, for datetime functions.
author Patrick Hurst <phurst@mit.edu>
date Sat, 25 Jan 2014 18:15:14 -0500
parents e90f218f2d48
children 819756825c8d
comparison
equal deleted inserted replaced
1981:e90f218f2d48 1982:2b95ecdd94eb
3937 return r; 3937 return r;
3938 } 3938 }
3939 3939
3940 uw_Basis_int uw_Basis_datetimeYear(uw_context ctx, uw_Basis_time time) { 3940 uw_Basis_int uw_Basis_datetimeYear(uw_context ctx, uw_Basis_time time) {
3941 struct tm tm; 3941 struct tm tm;
3942 gmtime_r(&time.seconds, &tm); 3942 localtime_r(&time.seconds, &tm);
3943 return tm.tm_year + 1900; 3943 return tm.tm_year + 1900;
3944 } 3944 }
3945 3945
3946 uw_Basis_int uw_Basis_datetimeMonth(uw_context ctx, uw_Basis_time time) { 3946 uw_Basis_int uw_Basis_datetimeMonth(uw_context ctx, uw_Basis_time time) {
3947 struct tm tm; 3947 struct tm tm;
3948 gmtime_r(&time.seconds, &tm); 3948 localtime_r(&time.seconds, &tm);
3949 return tm.tm_mon; 3949 return tm.tm_mon;
3950 } 3950 }
3951 3951
3952 uw_Basis_int uw_Basis_datetimeDay(uw_context ctx, uw_Basis_time time) { 3952 uw_Basis_int uw_Basis_datetimeDay(uw_context ctx, uw_Basis_time time) {
3953 struct tm tm; 3953 struct tm tm;
3954 gmtime_r(&time.seconds, &tm); 3954 localtime_r(&time.seconds, &tm);
3955 return tm.tm_mday; 3955 return tm.tm_mday;
3956 } 3956 }
3957 3957
3958 uw_Basis_int uw_Basis_datetimeHour(uw_context ctx, uw_Basis_time time) { 3958 uw_Basis_int uw_Basis_datetimeHour(uw_context ctx, uw_Basis_time time) {
3959 struct tm tm; 3959 struct tm tm;
3960 gmtime_r(&time.seconds, &tm); 3960 localtime_r(&time.seconds, &tm);
3961 return tm.tm_hour; 3961 return tm.tm_hour;
3962 } 3962 }
3963 3963
3964 uw_Basis_int uw_Basis_datetimeMinute(uw_context ctx, uw_Basis_time time) { 3964 uw_Basis_int uw_Basis_datetimeMinute(uw_context ctx, uw_Basis_time time) {
3965 struct tm tm; 3965 struct tm tm;
3966 gmtime_r(&time.seconds, &tm); 3966 localtime_r(&time.seconds, &tm);
3967 return tm.tm_min; 3967 return tm.tm_min;
3968 } 3968 }
3969 3969
3970 uw_Basis_int uw_Basis_datetimeSecond(uw_context ctx, uw_Basis_time time) { 3970 uw_Basis_int uw_Basis_datetimeSecond(uw_context ctx, uw_Basis_time time) {
3971 struct tm tm; 3971 struct tm tm;
3972 gmtime_r(&time.seconds, &tm); 3972 localtime_r(&time.seconds, &tm);
3973 return tm.tm_sec; 3973 return tm.tm_sec;
3974 } 3974 }
3975 3975
3976 uw_Basis_int uw_Basis_datetimeDayOfWeek(uw_context ctx, uw_Basis_time time) { 3976 uw_Basis_int uw_Basis_datetimeDayOfWeek(uw_context ctx, uw_Basis_time time) {
3977 struct tm tm; 3977 struct tm tm;
3978 gmtime_r(&time.seconds, &tm); 3978 localtime_r(&time.seconds, &tm);
3979 return tm.tm_wday; 3979 return tm.tm_wday;
3980 } 3980 }
3981 3981
3982 3982
3983 void *uw_get_global(uw_context ctx, char *name) { 3983 void *uw_get_global(uw_context ctx, char *name) {