GNOME Bugzilla – Bug 790779
date-time: Rewrite logic to get date difference
Last modified: 2017-12-01 16:41:59 UTC
.
Created attachment 364308 [details] [review] date-time: Rewrite logic to get date difference Blindly getting week, month, and year based on number of days won't work right. Let's use GDate to deduce this the right way. Also GTimeVal is always 32 bit. Which means that the application will break on 2038. Let's fix this so that mission critical systems running bijiben won't fail on the date. :-)
Review of attachment 364308 [details] [review]: + else if (diff < 7 && /* FIXME: Won't work if the week overlap two years */ + g_date_get_monday_week_of_year (date) == g_date_get_monday_week_of_year (now)) Why don't you check year as well? Another thing, for this chain of ifs, please add the braces, to help people to understand it better. Thanks.
(In reply to Isaque Galdino from comment #2) > Review of attachment 364308 [details] [review] [review]: > > + else if (diff < 7 && /* FIXME: Won't work if the week overlap two years > */ > + g_date_get_monday_week_of_year (date) == > g_date_get_monday_week_of_year (now)) > > Why don't you check year as well? That's done in the preceding conditional. > > Another thing, for this chain of ifs, please add the braces, to help people > to understand it better. > Shall do. > Thanks.
Created attachment 364652 [details] [review] date-time: Rewrite logic to get date difference Blindly getting week, month, and year based on number of days won't work right. Let's use GDate to deduce this the right way. Also GTimeVal is always 32 bit. Which means that the application will break on 2038. Let's fix this so that mission critical systems running bijiben won't fail on the date. :-)
(In reply to Mohammed Sadiq from comment #3) > (In reply to Isaque Galdino from comment #2) > > Review of attachment 364308 [details] [review] [review] [review]: > > > > + else if (diff < 7 && /* FIXME: Won't work if the week overlap two years > > */ > > + g_date_get_monday_week_of_year (date) == > > g_date_get_monday_week_of_year (now)) > > > > Why don't you check year as well? > > That's done in the preceding conditional. So, we don't need this FIXME comment, do we?
Created attachment 364751 [details] [review] date-time: Rewrite logic to get date difference Blindly getting week, month, and year based on number of days won't work right. Let's use GDate to deduce this the right way. Also GTimeVal is always 32 bit. Which means that the application will break on 2038. Let's fix this so that mission critical systems running bijiben won't fail on the date. :-) (In reply to Isaque Galdino from comment #5) > So, we don't need this FIXME comment, do we? Sorry, I misunderstood your comment. Anyway I have rewritten the code to fix weeks spanning to years too.
Review of attachment 364751 [details] [review]: Thanks.