]> Pileus Git - lackey/blobdiff - src/date.c
Add size function, update ical/week
[lackey] / src / date.c
index 965f15a4a6c4e8a4e8e3481e2828bc1e25f7eab4..2e1f7f8af1bd0a2666896454acba64e0a0732e9d 100644 (file)
@@ -38,9 +38,9 @@ void date_init(void)
        DAY   = tm->tm_mday-1;
 
        // Testing */
-       YEAR  = 2009;
-       MONTH = MAY;
-       DAY   = 1;
+       //YEAR  = 2009;
+       //MONTH = MAY;
+       //DAY   = 1;
 }
 
 /* Time functions */
@@ -111,6 +111,21 @@ void add_months(year_t *year, month_t *month, int months)
        *month = total % 12;
 }
 
+stamp_t get_time(date_t *date)
+{
+       return mktime(&(struct tm){
+               .tm_year = date->year-1900,
+               .tm_mon  = date->month,
+               .tm_mday = date->day+1,
+               .tm_hour = date->hour,
+               .tm_min  = date->min});
+}
+
+int get_mins(date_t *start, date_t *end)
+{
+       return (get_time(end)-get_time(start))/60;
+}
+
 /* Debug functions */
 const char *month_to_str(month_t month)
 {