From 61eb83337daac43e6c048549c0300bdde7af158a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Jun 2010 03:13:37 +0200 Subject: Fixed some off-by-one bugs --- .gitignore | 1 + DDate.vala | 4 ++-- DDateTest.vala | 7 +++++++ Makefile | 6 +++++- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 DDateTest.vala diff --git a/.gitignore b/.gitignore index fc5a6a3..f016f48 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ DClock +DDateTest diff --git a/DDate.vala b/DDate.vala index b29944d..7f9654d 100644 --- a/DDate.vala +++ b/DDate.vala @@ -66,14 +66,14 @@ public struct DDate { } public uchar get_day() { - return (uchar)(get_day_of_year() % 73); + return (uchar)(((get_day_of_year()-1) % 73) + 1); } public DDateMonth get_month() { if(is_st_tibs_day()) return DDateMonth.ST_TIBS_DAY; - return (DDateMonth)(get_day_of_year()/73); + return (DDateMonth)((get_day_of_year()-1)/73); } public DDateWeekday get_weekday() { diff --git a/DDateTest.vala b/DDateTest.vala new file mode 100644 index 0000000..487aed7 --- /dev/null +++ b/DDateTest.vala @@ -0,0 +1,7 @@ +void main() { + Date date = Date(); + date.set_dmy(15,3,2010); + DDate ddate = DDate(date); + + print(ddate.to_string() + "\n"); +} diff --git a/Makefile b/Makefile index 0d4c1bc..1463447 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ -all : DClock +all : DClock DDateTest DClock : DClock.vala DDate.vala valac --pkg=libpanelapplet-2.0 DClock.vala DDate.vala +DDateTest : DDateTest.vala DDate.vala + valac DDateTest.vala DDate.vala + + clean : rm -f DClock -- cgit v1.2.3