Exemplo n.º 1
0
TEST(gnc_timezone_constructors, test_bogus_time_constructor)
{
    TimeZoneProvider tzp ("New York Standard Time");
    TimeZoneProvider machine ("");
    EXPECT_TRUE(machine.get(2006)->std_zone_abbrev() ==
                tzp.get(2006)->std_zone_abbrev());
}
Exemplo n.º 2
0
TEST(gnc_timezone_constructors, test_default_constructor)
{
    TimeZoneProvider tzp {};
    EXPECT_NO_THROW (tzp.get(2014));
    TZ_Ptr tz = tzp.get (2014);

//Can't really test anything explicit, we don't know what to expect
//from the default TZ.
    EXPECT_FALSE(tz->std_zone_abbrev().empty());
}
Exemplo n.º 3
0
TEST(gnc_timezone_constructors, test_pacific_time_constructor)
{
#if PLATFORM(WINDOWS)
    std::string timzone("Pacific Standard Time");
#else
    std::string timezone("America/Los_Angeles");
#endif
    TimeZoneProvider tzp (timezone);
    EXPECT_NO_THROW (tzp.get(2006));
    TZ_Ptr tz = tzp.get (2006);

    EXPECT_FALSE(tz->std_zone_abbrev().empty());
#if PLATFORM(WINDOWS)
    EXPECT_TRUE(tz->std_zone_abbrev() == timezone);
#else
    EXPECT_TRUE(tz->std_zone_abbrev() == "PST");
    EXPECT_TRUE(tz->dst_zone_abbrev() == "PDT");
#endif
    EXPECT_TRUE(tz->base_utc_offset().hours() == -8);
}
Exemplo n.º 4
0
/** Private implementation of GncDateTime. See the documentation for that class.
 */
static LDT
LDT_from_unix_local(const time64 time)
{
    try
    {
        PTime temp(unix_epoch.date(),
                   boost::posix_time::hours(time / 3600) +
                   boost::posix_time::seconds(time % 3600));
        auto tz = tzp.get(temp.date().year());
        return LDT(temp, tz);
    }
    catch(boost::gregorian::bad_year)
    {
        throw(std::invalid_argument("Time value is outside the supported year range."));
    }
}
Exemplo n.º 5
0
static LDT
LDT_from_struct_tm(const struct tm tm)
{
    try
    {
        auto tdate = boost::gregorian::date_from_tm(tm);
        auto tdur = boost::posix_time::time_duration(tm.tm_hour, tm.tm_min,
                                                     tm.tm_sec, 0);
        auto tz = tzp.get(tdate.year());
        return LDT(PTime(tdate, tdur), tz);
    }
    catch(boost::gregorian::bad_year)
    {
        throw(std::invalid_argument("Time value is outside the supported year range."));
    }
}
Exemplo n.º 6
0
 void now() { m_time = boost::local_time::local_sec_clock::local_time(tzp.get(boost::gregorian::day_clock::local_day().year())); }
Exemplo n.º 7
0
 GncDateTimeImpl(PTime&& pt) : m_time(pt, tzp.get(pt.date().year())) {}
Exemplo n.º 8
0
 GncDateTimeImpl() : m_time(unix_epoch, tzp.get(unix_epoch.date().year())) {}
Exemplo n.º 9
0
 GncDateTimeImpl() : m_time(boost::local_time::local_sec_clock::local_time(tzp.get(boost::gregorian::day_clock::local_day().year()))) {}