Skip to content
  • Allison Karlitskaya's avatar
    GDateTime test: fix occasional failures · 419f5713
    Allison Karlitskaya authored
    We were using the time() library call to get the current time from the
    system in order to compare it to the time returned by
    g_date_time_new_now().
    
    Of course, we took care to ensure that the time (in seconds) didn't
    change in the middle of this process by checking the before and after
    value of the system time.
    
    Unfortunately, the system time as measured by time() was being taken
    from a less-accurate clock source than the time used by GDateTime.  As a
    result, we could have GDateTime already into the next second while the
    "seconds" value of the time returned by time() was still in the last
    one, even when checked "after".
    
    Avoid the problem by using the same ultimate source for time --
    g_get_real_time().
    
    This is based on a similar patch from Iain Lane, but it uses
    g_get_real_time() instead of g_get_current_time().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754994
    419f5713