diff options
author | Deiz <silverwraithii@gmail.com> | 2012-10-15 13:56:17 -0400 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2012-10-16 09:25:38 +0200 |
commit | 04dc34f27d63eeda3e7f68a67151da97aeb5c2a8 (patch) | |
tree | 239a4aaf6edce78d1b2eccc6dd03b6a8c649eaf3 /src/print_ddate.c | |
parent | 794151cfe76f80fb2c7eebb8d3fbbce8fc5ccb09 (diff) |
Skip a day in the Discordian calendar when St. Tib's Day has passed
Diffstat (limited to 'src/print_ddate.c')
-rw-r--r-- | src/print_ddate.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/print_ddate.c b/src/print_ddate.c index ce94759..30bdc52 100644 --- a/src/print_ddate.c +++ b/src/print_ddate.c @@ -180,20 +180,22 @@ struct disc_time *get_ddate(struct tm *current_tm) { int is_leap_year = !(current_tm->tm_year % 4) && (!(current_tm->tm_year % 400) || current_tm->tm_year % 100); - if (is_leap_year && current_tm->tm_yday == 59) { + /* If St. Tib's Day has passed, it will be necessary to skip a day. */ + int yday = current_tm->tm_yday; + + if (is_leap_year && yday == 59) { /* On St. Tibs Day we don't have to define a date */ dt.st_tibs_day = 1; } else { dt.st_tibs_day = 0; - dt.season_day = current_tm->tm_yday % 73; - if (is_leap_year && current_tm->tm_yday > 59) { - dt.week_day = (current_tm->tm_yday - 1) % 5; - } else { - dt.week_day = current_tm->tm_yday % 5; - } + if (is_leap_year && yday > 59) + yday -= 1; + + dt.season_day = yday % 73; + dt.week_day = yday % 5; } dt.year = current_tm->tm_year + 3066; - dt.season = current_tm->tm_yday / 73; + dt.season = yday / 73; return &dt; } |