aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/timeutil.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-03-11 09:35:52 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-03-11 09:35:52 +0800
commit20bba8a8f67d1e347d00748b03908f948c2be6b7 (patch)
tree0b11710b8773a51ec11385af05606aa80332f303 /calendar/timeutil.c
parent1b383b0fa71f05423f333fc0afcd049a643dca74 (diff)
downloadgsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar.gz
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar.bz2
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar.lz
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar.xz
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.tar.zst
gsoc2013-evolution-20bba8a8f67d1e347d00748b03908f948c2be6b7.zip
1999-03-10 Craig A Soules (soules+@andrew.cmu.edu)
* timeutil.c, calendar.c, calobj.c, gncal-day-panel.c: Add support for daylight time savings. svn path=/trunk/; revision=756
Diffstat (limited to 'calendar/timeutil.c')
-rw-r--r--calendar/timeutil.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index 07a1514c80..c03f2cb565 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -109,13 +109,24 @@ time_add_day (time_t time, int days)
{
struct tm *tm = localtime (&time);
time_t new_time;
+ int dst_flag = tm->tm_isdst;
tm->tm_mday += days;
+
if ((new_time = mktime (tm)) == -1){
g_warning ("mktime could not handling adding a day with\n");
print_time_t (time);
return time;
}
+
+ if (dst_flag > tm->tm_isdst){
+ tm->tm_hour++;
+ new_time += 3600;
+ } else if (dst_flag < tm->tm_isdst){
+ tm->tm_hour--;
+ new_time -= 3600;
+ }
+
return new_time;
}
@@ -306,27 +317,60 @@ time_t
time_day_begin (time_t t)
{
struct tm tm;
+ time_t temp = t - 43200;
+ int dstflag, dstflag2;
+ tm = *localtime(&temp); /* one day */
+ dstflag = tm.tm_isdst;
+
tm = *localtime (&t);
- tm.tm_hour = 0;
+ dstflag2 = tm.tm_isdst;
+
+ if (dstflag < dstflag2)
+ tm.tm_hour = 1;
+ else
+ tm.tm_hour = 0;
+
tm.tm_min = 0;
tm.tm_sec = 0;
+
+ temp = mktime(&tm);
+ if (dstflag > dstflag2){
+ temp += 3600;
+ }
- return mktime (&tm);
+ return temp;
}
time_t
time_day_end (time_t t)
{
struct tm tm;
-
+ time_t temp;
+ int dstflag, dstflag2;
+
+ t += 10800;
+ temp = t - 86400;
+
+ tm = *localtime(&temp); /* one day */
+ dstflag = tm.tm_isdst;
+
tm = *localtime (&t);
- tm.tm_hour = 0;
+ dstflag2 = tm.tm_isdst;
+
+ if (dstflag < dstflag2)
+ tm.tm_hour = 23;
+ else {
+ tm.tm_mday++;
+ tm.tm_hour = 0;
+ }
tm.tm_min = 0;
tm.tm_sec = 0;
- tm.tm_mday++;
- return mktime (&tm);
+ temp = mktime(&tm);
+ if(dstflag > dstflag2) {
+ }
+ return temp;
}
static char *