After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790779 - date-time: Rewrite logic to get date difference
date-time: Rewrite logic to get date difference
Status: RESOLVED FIXED
Product: bijiben
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Bijiben maintainer(s)
Bijiben maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-11-24 07:44 UTC by Mohammed Sadiq
Modified: 2017-12-01 16:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
date-time: Rewrite logic to get date difference (2.53 KB, patch)
2017-11-24 07:44 UTC, Mohammed Sadiq
none Details | Review
date-time: Rewrite logic to get date difference (2.62 KB, patch)
2017-11-30 03:34 UTC, Mohammed Sadiq
none Details | Review
date-time: Rewrite logic to get date difference (2.54 KB, patch)
2017-12-01 13:05 UTC, Mohammed Sadiq
committed Details | Review

Description Mohammed Sadiq 2017-11-24 07:44:08 UTC
.
Comment 1 Mohammed Sadiq 2017-11-24 07:44:16 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. :-)
Comment 2 Isaque Galdino 2017-11-29 17:02:09 UTC
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.
Comment 3 Mohammed Sadiq 2017-11-30 03:28:41 UTC
(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.
Comment 4 Mohammed Sadiq 2017-11-30 03:34:35 UTC
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. :-)
Comment 5 Isaque Galdino 2017-12-01 10:31:12 UTC
(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?
Comment 6 Mohammed Sadiq 2017-12-01 13:05:12 UTC
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.
Comment 7 Isaque Galdino 2017-12-01 16:41:43 UTC
Review of attachment 364751 [details] [review]:

Thanks.