[gnote] Switch SyncClient from sharp::DateTime to Glib::DateTime



commit 53c61719f49a7e11ff55dc29df3c5a51f57637f0
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 25 15:15:42 2020 +0200

    Switch SyncClient from sharp::DateTime to Glib::DateTime

 src/synchronization/gnotesyncclient.cpp | 12 ++++++------
 src/synchronization/gnotesyncclient.hpp |  8 ++++----
 src/synchronization/isyncmanager.hpp    |  4 ++--
 src/synchronization/syncmanager.cpp     |  2 +-
 src/test/unit/gnotesyncclientutests.cpp |  6 +++---
 5 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/src/synchronization/gnotesyncclient.cpp b/src/synchronization/gnotesyncclient.cpp
index 2b9318af..8c4a9445 100644
--- a/src/synchronization/gnotesyncclient.cpp
+++ b/src/synchronization/gnotesyncclient.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2014,2017,2019 Aurimas Cernius
+ * Copyright (C) 2012-2014,2017,2019-2020 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -141,14 +141,14 @@ namespace sync {
   void GnoteSyncClient::parse(const Glib::ustring & manifest_path)
   {
     // Set defaults before parsing
-    m_last_sync_date = sharp::DateTime::now().add_days(-1);
+    m_last_sync_date = Glib::DateTime::create_now_local().add_days(-1);
     m_last_sync_rev = -1;
     m_file_revisions.clear();
     m_deleted_notes.clear();
     m_server_id = "";
 
     if(!sharp::file_exists(manifest_path)) {
-      m_last_sync_date = sharp::DateTime();
+      m_last_sync_date = Glib::DateTime();
       write(manifest_path);
     }
 
@@ -158,7 +158,7 @@ namespace sync {
        if(reader.get_name() == "last-sync-date") {
          Glib::ustring value = reader.read_string();
          try {
-           m_last_sync_date = sharp::DateTime::from_iso8601(value);
+           m_last_sync_date = sharp::date_time_from_iso8601(value);
          }
          catch(...) {
             /* TRANSLATORS: %s is file */
@@ -198,7 +198,7 @@ namespace sync {
       xml.write_start_element("", "manifest", "http://beatniksoftware.com/tomboy";);
 
       xml.write_start_element("", "last-sync-date", "");
-      xml.write_string(m_last_sync_date.to_iso8601());
+      xml.write_string(sharp::date_time_to_iso8601(m_last_sync_date));
       xml.write_end_element();
 
       xml.write_start_element("", "last-sync-rev", "");
@@ -241,7 +241,7 @@ namespace sync {
   }
 
 
-  void GnoteSyncClient::last_sync_date(const sharp::DateTime & date)
+  void GnoteSyncClient::last_sync_date(const Glib::DateTime & date)
   {
     m_last_sync_date = date;
     // If we just did a sync, we should be able to forget older deleted notes
diff --git a/src/synchronization/gnotesyncclient.hpp b/src/synchronization/gnotesyncclient.hpp
index 26059340..35d836b8 100644
--- a/src/synchronization/gnotesyncclient.hpp
+++ b/src/synchronization/gnotesyncclient.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2014,2017,2019 Aurimas Cernius
+ * Copyright (C) 2012-2014,2017,2019-2020 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,11 +34,11 @@ namespace sync {
     static SyncClient *create(NoteManagerBase &);
     GnoteSyncClient();
 
-    virtual sharp::DateTime last_sync_date() override
+    virtual Glib::DateTime last_sync_date() override
       {
         return m_last_sync_date;
       }
-    virtual void last_sync_date(const sharp::DateTime &) override;
+    virtual void last_sync_date(const Glib::DateTime &) override;
     virtual int last_synchronized_revision() override
       {
         return m_last_sync_rev;
@@ -73,7 +73,7 @@ namespace sync {
     void read_notes(sharp::XmlReader & reader, void (GnoteSyncClient::*read_note_atts)(sharp::XmlReader&));
 
     Glib::RefPtr<Gio::FileMonitor> m_file_watcher;
-    sharp::DateTime m_last_sync_date;
+    Glib::DateTime m_last_sync_date;
     int m_last_sync_rev;
     Glib::ustring m_server_id;
     std::map<Glib::ustring, int> m_file_revisions;
diff --git a/src/synchronization/isyncmanager.hpp b/src/synchronization/isyncmanager.hpp
index 373df76f..8b0c477f 100644
--- a/src/synchronization/isyncmanager.hpp
+++ b/src/synchronization/isyncmanager.hpp
@@ -48,8 +48,8 @@ public:
 
   virtual int last_synchronized_revision() = 0;
   virtual void last_synchronized_revision(int) = 0;
-  virtual sharp::DateTime last_sync_date() = 0;
-  virtual void last_sync_date(const sharp::DateTime &) = 0;
+  virtual Glib::DateTime last_sync_date() = 0;
+  virtual void last_sync_date(const Glib::DateTime &) = 0;
   virtual int get_revision(const NoteBase::Ptr & note) = 0;
   virtual void set_revision(const NoteBase::Ptr & note, int revision) = 0;
   virtual std::map<Glib::ustring, Glib::ustring> deleted_note_titles() = 0;
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index b1fa4a4c..f262e7f7 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -354,7 +354,7 @@ namespace sync {
       // This should be equivalent to newRevision
       m_client->last_synchronized_revision(server->latest_revision());
 
-      m_client->last_sync_date(sharp::DateTime::now());
+      m_client->last_sync_date(Glib::DateTime::create_now_local());
 
       DBG_OUT("Sync: New revision: %d", m_client->last_synchronized_revision());
 
diff --git a/src/test/unit/gnotesyncclientutests.cpp b/src/test/unit/gnotesyncclientutests.cpp
index f33e1b38..ed190c35 100644
--- a/src/test/unit/gnotesyncclientutests.cpp
+++ b/src/test/unit/gnotesyncclientutests.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2017,2019 Aurimas Cernius
+ * Copyright (C) 2017,2019-2020 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -75,8 +75,8 @@ TEST(manifest_parsing)
   client.set_manifest_path(test_manifest);
   client.reparse();
 
-  sharp::DateTime sync_date(sharp::DateTime::from_iso8601("2014-04-21T20:13:24.711343Z"));
-  CHECK(client.last_sync_date() == sync_date);
+  auto sync_date = sharp::date_time_from_iso8601("2014-04-21T20:13:24.711343Z");
+  CHECK(client.last_sync_date().compare(sync_date) == 0);
   CHECK_EQUAL(0, client.last_synchronized_revision());
   CHECK_EQUAL("38afddc2-9ce8-46ba-b106-baf3916c74b8", client.associated_server_id());
   CHECK_EQUAL(3, client.deleted_note_titles().size());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]