Ejemplo n.º 1
0
TEST(DateTime,ISO8601Conversions) {
  {
    DateTime dateTime = DateTime::now();
    double utcOffset = dateTime.utcOffset();
    EXPECT_EQ(DateTime::localOffsetUTC(), utcOffset);

    std::string asIso = dateTime.toISO8601();
    OptionalDateTime copy = DateTime::fromISO8601(asIso);
    ASSERT_TRUE(copy);
    EXPECT_EQ(dateTime, copy.get());
    EXPECT_EQ(dateTime.utcOffset(), copy->utcOffset());
    EXPECT_EQ(dateTime.toEpoch(), copy->toEpoch());
  }
  {
    DateTime dateTime = DateTime::nowUTC();
    double utcOffset = dateTime.utcOffset();
    EXPECT_EQ(0, utcOffset);

    std::string asIso = dateTime.toISO8601();
    OptionalDateTime copy = DateTime::fromISO8601(asIso);
    ASSERT_TRUE(copy);
    EXPECT_EQ(dateTime, copy.get());
    EXPECT_EQ(dateTime.utcOffset(), copy->utcOffset());
    EXPECT_EQ(dateTime.toEpoch(), copy->toEpoch());
  }
}
Ejemplo n.º 2
0
TEST(DateTime,ISO8601Conversions) {
  DateTime dateTime = DateTime::now();
  std::string asIso = dateTime.toISO8601();
  OptionalDateTime copy = DateTime::fromISO8601(asIso);
  ASSERT_TRUE(copy);
  EXPECT_EQ(dateTime,copy.get());
}
Ejemplo n.º 3
0
 FileReference toFileReference(const QVariant& variant, const VersionString& version) {
   QVariantMap map = variant.toMap();
   OptionalDateTime timestampLast;
   if (version < VersionString("1.0.4")) {
     timestampLast = DateTime(map["timestamp_last"].toString().toStdString());
   }
   else {
     timestampLast = DateTime::fromISO8601(map["timestamp_last"].toString().toStdString());
   }
   OS_ASSERT(timestampLast);
   return FileReference(toUUID(map["uuid"].toString().toStdString()),
                        toUUID(map["version_uuid"].toString().toStdString()),
                        map.contains("name") ? map["name"].toString().toStdString() : std::string(),
                        map.contains("display_name") ? map["display_name"].toString().toStdString() : std::string(),
                        map.contains("description") ? map["description"].toString().toStdString() : std::string(),
                        toPath(map["path"].toString()),
                        FileReferenceType(map["file_type"].toString().toStdString()),
                        timestampLast.get(),
                        map["checksum_create"].toString().toStdString(),
                        map["checksum_last"].toString().toStdString());
 }