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



commit 53beb24e4223874162455f4d1c66dcecfccc91bc
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Wed Jan 22 22:39:55 2020 +0200

    Switch notedirectorywatcher from sharp::DateTime to Glib::DateTime

 .../notedirectorywatcherapplicationaddin.cpp                   | 10 +++++-----
 .../notedirectorywatcherapplicationaddin.hpp                   |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp 
b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
index a415af48..f9dfdd1f 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
+++ b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
@@ -87,7 +87,7 @@ bool NoteDirectoryWatcherApplicationAddin::initialized()
 
 void NoteDirectoryWatcherApplicationAddin::handle_note_saved(const gnote::NoteBase::Ptr & note)
 {
-  m_note_save_times[note->id()] = sharp::DateTime::now();
+  m_note_save_times[note->id()] = Glib::DateTime::create_now_local();
 }
 
 void NoteDirectoryWatcherApplicationAddin::handle_file_system_change_event(
@@ -135,7 +135,7 @@ void NoteDirectoryWatcherApplicationAddin::handle_file_system_change_event(
       }
     }
 
-    record->second.last_change = sharp::DateTime::now();
+    record->second.last_change = Glib::DateTime::create_now_local();
   }
   catch(...)
   {}
@@ -167,15 +167,15 @@ bool NoteDirectoryWatcherApplicationAddin::handle_timeout()
 
       // Check that Note.Saved event didn't occur within (check-interval -2) seconds of last write
       if(m_note_save_times.find(iter.first) != m_note_save_times.end() &&
-          std::abs(sharp::time_span_total_seconds(m_note_save_times[iter.first] - iter.second.last_change)) 
<= (m_check_interval - 2)) {
+          
std::abs(sharp::time_span_total_seconds(m_note_save_times[iter.first].difference(iter.second.last_change))) 
<= (m_check_interval - 2)) {
         DBG_OUT("NoteDirectoryWatcher: Ignoring (timeout) because it was probably a Gnote write");
         keysToRemove.push_back(iter.first);
         continue;
       }
       // TODO: Take some actions to clear note_save_times? Not a large structure...
 
-      sharp::DateTime last_change(iter.second.last_change);
-      if(sharp::DateTime::now() > last_change.add_seconds(4)) {
+      Glib::DateTime last_change(iter.second.last_change);
+      if(Glib::DateTime::create_now_local() > last_change.add_seconds(4)) {
         if(iter.second.deleted) {
           delete_note(iter.first);
         }
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.hpp 
b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.hpp
index e075e66d..7d024de9 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.hpp
+++ b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.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
@@ -46,7 +46,7 @@ DECLARE_MODULE(NoteDirectoryWatcherModule);
 
 struct NoteFileChangeRecord
 {
-  sharp::DateTime last_change;
+  Glib::DateTime last_change;
   bool deleted;
   bool changed;
 };
@@ -81,7 +81,7 @@ private:
   Glib::RefPtr<Gio::FileMonitor> m_file_system_watcher;
 
   std::map<Glib::ustring, NoteFileChangeRecord> m_file_change_records;
-  std::map<Glib::ustring, sharp::DateTime> m_note_save_times;
+  std::map<Glib::ustring, Glib::DateTime> m_note_save_times;
   sigc::connection m_signal_note_saved_cid;
   sigc::connection m_signal_changed_cid;
   sigc::connection m_signal_settings_changed_cid;


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