Stop testing fractional seconds.

We don't use them in real code, so the new implementation isn't going to
support them.
This commit is contained in:
John Ralls 2015-04-28 17:47:47 -07:00
parent a8028ec7f2
commit ac515d6ce2
6 changed files with 8 additions and 40 deletions

View File

@ -224,20 +224,7 @@ get_random_timespec(void)
while (ret->tv_sec <= 0)
ret->tv_sec = rand();
if (zero_nsec)
ret->tv_nsec = 0;
else
{
ret->tv_nsec = rand();
if (usec_resolution)
{
ret->tv_nsec = MIN (ret->tv_nsec, 999999999);
ret->tv_nsec /= 1000;
ret->tv_nsec *= 1000;
}
}
ret->tv_nsec = 0;
return ret;
}

View File

@ -325,7 +325,7 @@ run_test (void)
check_time (ts, do_print);
ts.tv_sec = 1162088421;
ts.tv_nsec = 12548000;
ts.tv_nsec = 0;
check_time (ts, do_print);
ts.tv_sec = 325659000 - 6500;
@ -337,15 +337,15 @@ run_test (void)
check_time (ts, do_print);
ts.tv_sec = 1603591171;
ts.tv_nsec = 595311000;
ts.tv_nsec = 0;
check_time (ts, do_print);
ts.tv_sec = 1738909365;
ts.tv_nsec = 204102000;
ts.tv_nsec = 0;
check_time (ts, do_print);
ts.tv_sec = 1603591171;
ts.tv_nsec = 595311000;
ts.tv_nsec = 0;
check_time (ts, do_print);
ts.tv_sec = 1143943200 - 1;

View File

@ -1246,12 +1246,11 @@ Timespec
gnc_iso8601_to_timespec_gmt(const char *cstr)
{
time64 time;
uint32_t nsecs;
if (!cstr) return {0, 0};
try
{
GncDateTime gncdt(cstr);
return {static_cast<time64>(gncdt), gncdt.nsecs()};
return {static_cast<time64>(gncdt), 0};
}
catch(...)
{

View File

@ -126,7 +126,6 @@ public:
operator struct tm() const;
void now() { m_time = boost::local_time::local_sec_clock::local_time(tzp.get(boost::gregorian::day_clock::local_day().year())); }
long offset() const;
long nsecs() const;
struct tm utc_tm() const { return to_tm(m_time.utc_time()); }
std::unique_ptr<GncDateImpl> date() const;
std::string format(const char* format) const;
@ -186,12 +185,6 @@ GncDateTimeImpl::offset() const
return offset.total_seconds();
}
long
GncDateTimeImpl::nsecs() const
{
return (m_time.utc_time() - unix_epoch).ticks() % ticks_per_second;
}
std::unique_ptr<GncDateImpl>
GncDateTimeImpl::date() const
{
@ -265,12 +258,6 @@ GncDateTime::offset() const
return m_impl->offset();
}
long
GncDateTime::nsecs() const
{
return m_impl->nsecs();
}
struct tm
GncDateTime::utc_tm() const
{

View File

@ -131,11 +131,6 @@ public:
* is negative.
*/
long offset()const;
/** Obtain the fractional seconds from the GncDateTime
* @return Fractional seconds, represented as nanoseconds, associated
* with the time.
*/
long nsecs() const;
/** Obtain a struct tm representing the time in UTC.
* @return struct tm
*/

View File

@ -93,7 +93,7 @@ static void setup (FixtureA *f, gconstpointer pData)
f->off_zulu = (TZOffset){0, 0};
f->off_05w = (TZOffset){-5, 0};
f->off_0840e = (TZOffset){8, 40};
f->ts1 = (Timespec){607009407, 345678000}; //1989-3-27 13:43:27.345678 Z
f->ts1 = (Timespec){607009407, 0}; //1989-3-27 13:43:27 Z
f->ts2 = (Timespec){1604748079, 0}; //2020-11-7 06:21:19 -05:00
f->ts3 = (Timespec){1341398864, 0}; //2012-07-04 19:27:44 +08:40
f->ts4 = (Timespec){-261104801, 0}; //1961-09-22 17:53:19 -05:00
@ -1590,7 +1590,7 @@ test_gnc_iso8601_to_timespec_gmt (FixtureA *f, gconstpointer pData)
g_assert_cmpint (t.tv_sec, ==, 0);
g_assert_cmpint (t.tv_nsec, ==, 0);
t = gnc_iso8601_to_timespec_gmt ("1989-03-27 13:43:27.345678");
t = gnc_iso8601_to_timespec_gmt ("1989-03-27 13:43:27");
g_assert_cmpint (t.tv_sec, ==, f->ts1.tv_sec);
/* MinGW has some precision issues in the last microsecond digit */
#ifdef G_OS_WIN32