[bugs] [PATCH] Modify date2tm to set the day of the week and day of the year.

Replace the usage of localtime by a call to mktime after setting
the tm struct's fields. This allows the tm_wday and tm_yday to be
set correctly for the requested date.
---
 src/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/utils.c b/src/utils.c
index 50f2507..3fce9fb 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -368,10 +368,9 @@ int get_item_min(long date)
 
 struct tm date2tm(struct date day, unsigned hour, unsigned min)
 {
-	time_t t = now();
 	struct tm start;
 
-	localtime_r(&t, &start);
+	memset(&start,0,sizeof(struct tm));
 
 	start.tm_mon = day.mm - 1;
 	start.tm_mday = day.dd;
@@ -381,6 +380,7 @@ struct tm date2tm(struct date day, unsigned hour, unsigned min)
 	start.tm_sec = 0;
 	start.tm_isdst = -1;
 
+	mktime(&start);
 	return start;
 }
 
-- 
2.1.4

Links