Commits

Trammell Hudson committed c71852a

Change gmt offset to minutes instead of hours to support India

  • Participants
  • Parent commits aa9b307

Comments (0)

Files changed (1)

File timezones/src/tz.c

 
 
 // Local timezone GMT offset
-static const int gmt_offset = -5;
+static const int gmt_offset = -5 * 60;
 
 #define NUM_TIMEZONES 3
 #define LAYER_HEIGHT (PEBBLE_SCREEN_HEIGHT / NUM_TIMEZONES)
 
 static timezone_t timezones[NUM_TIMEZONES] =
 {
-	{ .name = "New York", .offset = -5 },
-	{ .name = "London", .offset = +0 },
-	{ .name = "Tokyo", .offset = +8 },
+	{ .name = "New York", .offset = -5 * 60 },
+	{ .name = "London", .offset = +0 * 60 },
+	{ .name = "India", .offset = +(5 * 60 + 30) },
 };
 
 
 	const timezone_t * const tz = container_of(me, timezone_t, layer);
 
 	const int orig_hour = now.tm_hour;
+	const int orig_min = now.tm_min;
 
-	now.tm_hour += tz->offset - gmt_offset;
+	now.tm_min += (tz->offset - gmt_offset) % 60;
+	if (now.tm_min > 60)
+	{
+		now.tm_hour++;
+		now.tm_min -= 60;
+	} else
+	if (now.tm_min < 0)
+	{
+		now.tm_hour--;
+		now.tm_min += 60;
+	}
+
+	now.tm_hour += (tz->offset - gmt_offset) / 60;
 	if (now.tm_hour > 24)
 		now.tm_hour -= 24;
 	if (now.tm_hour < 0)
 
 	const int night_time = (now.tm_hour > 18 || now.tm_hour < 6);
 	now.tm_hour = orig_hour;
+	now.tm_min = orig_min;
 
 	const int w = me->bounds.size.w;
 	const int h = me->bounds.size.h;