Work around the way g_date_time_new truncates microseconds.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22612 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls
2012-12-01 22:43:25 +00:00
parent bd13635a9a
commit 2c26cb7777

View File

@@ -162,6 +162,13 @@ gnc_g_date_time_new_local (gint year, gint month, gint day, gint hour, gint minu
return gdt;
tz = gnc_g_time_zone_adjust_for_dst (tz, gdt);
g_date_time_unref (gdt);
/* g_date_time_new truncates nanoseconds to microseconds. Sometimes in
* converting (particularly when parsing from a string) the
* nanoseconds will have lost 1/2 a femtosecond or so. Adding 1/2 a
* nano second ensures that the truncation doesn't lose a micorsecond
* in translation.
*/
seconds += 5e-10;
gdt = g_date_time_new (tz, year, month, day, hour, minute, seconds);
g_time_zone_unref (tz);
return gdt;
@@ -1427,7 +1434,10 @@ gnc_iso8601_to_timespec_gmt(const char *str)
g_time_zone_unref (tz);
}
else /* No zone info, assume UTC */
{
second += 5e-10;
gdt = g_date_time_new_utc (year, month, day, hour, minute, second);
}
time.tv_sec = g_date_time_to_unix (gdt);
time.tv_nsec = g_date_time_get_microsecond (gdt) * 1000;