[gnote] Switch Note from sharp::DateTime to Glib::DateTime
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Switch Note from sharp::DateTime to Glib::DateTime
- Date: Sat, 25 Jan 2020 13:42:59 +0000 (UTC)
commit 59da0417f72e0b56801516c6b0f890b76115259b
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Jan 25 15:30:01 2020 +0200
Switch Note from sharp::DateTime to Glib::DateTime
src/dbus/remotecontrol.cpp | 6 +++---
src/note.cpp | 14 +++++++-------
src/notebase.cpp | 16 ++++++++--------
src/notebase.hpp | 26 +++++++++++++-------------
src/searchnoteswidget.cpp | 4 ++--
src/sharp/xmlconvert.cpp | 10 +++++-----
src/sharp/xmlconvert.hpp | 6 +++---
7 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/src/dbus/remotecontrol.cpp b/src/dbus/remotecontrol.cpp
index acd88a7a..3b256ddb 100644
--- a/src/dbus/remotecontrol.cpp
+++ b/src/dbus/remotecontrol.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014,2016-2017,2019 Aurimas Cernius
+ * Copyright (C) 2011-2014,2016-2017,2019-2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -185,7 +185,7 @@ namespace gnote {
NoteBase::Ptr note = m_manager.find_by_uri(uri);
if (!note)
return -1;
- return note->metadata_change_date().sec();
+ return note->metadata_change_date().to_unix();
}
@@ -222,7 +222,7 @@ namespace gnote {
NoteBase::Ptr note = m_manager.find_by_uri(uri);
if (!note)
return -1;
- return note->create_date().sec();
+ return note->create_date().to_unix();
}
diff --git a/src/note.cpp b/src/note.cpp
index 2011570c..e2b97edd 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2017,2019 Aurimas Cernius
+ * Copyright (C) 2010-2017,2019-2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -277,7 +277,7 @@ namespace gnote {
{
auto note_data = std::make_unique<NoteData>(url_from_path(filename));
note_data->title() = title;
- sharp::DateTime date(sharp::DateTime::now());
+ auto date(Glib::DateTime::create_now_local());
note_data->create_date() = date;
note_data->set_change_date(date);
@@ -286,16 +286,16 @@ namespace gnote {
Note::Ptr Note::create_existing_note(std::unique_ptr<NoteData> data, Glib::ustring filepath, NoteManager &
manager, IGnote & g)
{
- if (!data->change_date().is_valid()) {
- sharp::DateTime d(sharp::file_modification_time(filepath));
+ if (!data->change_date()) {
+ auto d(sharp::file_modification_time(filepath));
data->set_change_date(d);
}
- if (!data->create_date().is_valid()) {
- if(data->change_date().is_valid()) {
+ if (!data->create_date()) {
+ if(data->change_date()) {
data->create_date() = data->change_date();
}
else {
- sharp::DateTime d(sharp::file_modification_time(filepath));
+ auto d(sharp::file_modification_time(filepath));
data->create_date() = d;
}
}
diff --git a/src/notebase.cpp b/src/notebase.cpp
index f33fe81c..dccb6593 100644
--- a/src/notebase.cpp
+++ b/src/notebase.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014,2017,2019 Aurimas Cernius
+ * Copyright (C) 2011-2014,2017,2019-2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -171,14 +171,14 @@ void NoteBase::set_change_type(ChangeType c)
{
case CONTENT_CHANGED:
// NOTE: Updating ChangeDate automatically updates MetdataChangeDate to match.
- data_synchronizer().data().set_change_date(sharp::DateTime::now());
+ data_synchronizer().data().set_change_date(Glib::DateTime::create_now_local());
break;
case OTHER_DATA_CHANGED:
// Only update MetadataChangeDate. Used by sync/etc
// to know when non-content note data has changed,
// but order of notes in menu and search UI is
// unaffected.
- data_synchronizer().data().metadata_change_date() = sharp::DateTime::now();
+ data_synchronizer().data().metadata_change_date() = Glib::DateTime::create_now_local();
break;
default:
break;
@@ -383,17 +383,17 @@ NoteData & NoteBase::data()
return data_synchronizer().synchronized_data();
}
-const sharp::DateTime & NoteBase::create_date() const
+const Glib::DateTime & NoteBase::create_date() const
{
return data_synchronizer().data().create_date();
}
-const sharp::DateTime & NoteBase::change_date() const
+const Glib::DateTime & NoteBase::change_date() const
{
return data_synchronizer().data().change_date();
}
-const sharp::DateTime & NoteBase::metadata_change_date() const
+const Glib::DateTime & NoteBase::metadata_change_date() const
{
return data_synchronizer().data().metadata_change_date();
}
@@ -401,7 +401,7 @@ const sharp::DateTime & NoteBase::metadata_change_date() const
bool NoteBase::is_new() const
{
const NoteDataBufferSynchronizerBase & sync(data_synchronizer());
- return sync.data().create_date().is_valid() && (sync.data().create_date() >
sharp::DateTime::now().add_hours(-24));
+ return sync.data().create_date() && (sync.data().create_date() > sharp::DateTime::now().add_hours(-24));
}
void NoteBase::enabled(bool is_enabled)
@@ -575,7 +575,7 @@ void NoteArchiver::write(sharp::XmlWriter & xml, const NoteData & data)
xml.write_string(sharp::XmlConvert::to_string(data.metadata_change_date()));
xml.write_end_element();
- if(data.create_date().is_valid()) {
+ if(data.create_date()) {
xml.write_start_element("", "create-date", "");
xml.write_string(sharp::XmlConvert::to_string(data.create_date()));
xml.write_end_element();
diff --git a/src/notebase.hpp b/src/notebase.hpp
index 81633113..5a733f8a 100644
--- a/src/notebase.hpp
+++ b/src/notebase.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014,2017,2019 Aurimas Cernius
+ * Copyright (C) 2011-2014,2017,2019-2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -68,28 +68,28 @@ public:
{
return m_text;
}
- const sharp::DateTime & create_date() const
+ const Glib::DateTime & create_date() const
{
return m_create_date;
}
- sharp::DateTime & create_date()
+ Glib::DateTime & create_date()
{
return m_create_date;
}
- const sharp::DateTime & change_date() const
+ const Glib::DateTime & change_date() const
{
return m_change_date;
}
- void set_change_date(const sharp::DateTime & date)
+ void set_change_date(const Glib::DateTime & date)
{
m_change_date = date;
m_metadata_change_date = date;
}
- const sharp::DateTime & metadata_change_date() const
+ const Glib::DateTime & metadata_change_date() const
{
return m_metadata_change_date;
}
- sharp::DateTime & metadata_change_date()
+ Glib::DateTime & metadata_change_date()
{
return m_metadata_change_date;
}
@@ -141,9 +141,9 @@ private:
const Glib::ustring m_uri;
Glib::ustring m_title;
Glib::ustring m_text;
- sharp::DateTime m_create_date;
- sharp::DateTime m_change_date;
- sharp::DateTime m_metadata_change_date;
+ Glib::DateTime m_create_date;
+ Glib::DateTime m_change_date;
+ Glib::DateTime m_metadata_change_date;
int m_cursor_pos;
int m_selection_bound_pos;
int m_width, m_height;
@@ -238,9 +238,9 @@ public:
const NoteData & data() const;
NoteData & data();
- const sharp::DateTime & create_date() const;
- const sharp::DateTime & change_date() const;
- const sharp::DateTime & metadata_change_date() const;
+ const Glib::DateTime & create_date() const;
+ const Glib::DateTime & change_date() const;
+ const Glib::DateTime & metadata_change_date() const;
bool is_new() const;
bool enabled() const
{
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 15b028f5..de76c330 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2015,2017,2019 Aurimas Cernius
+ * Copyright (C) 2010-2015,2017,2019-2020 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -618,7 +618,7 @@ int SearchNotesWidget::compare_dates(const Gtk::TreeIter & a, const Gtk::TreeIte
return -1;
}
else {
- return sharp::DateTime::compare(note_a->change_date(), note_b->change_date());
+ return note_a->change_date().compare(note_b->change_date());
}
}
diff --git a/src/sharp/xmlconvert.cpp b/src/sharp/xmlconvert.cpp
index c412b1f7..a7b867a5 100644
--- a/src/sharp/xmlconvert.cpp
+++ b/src/sharp/xmlconvert.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2017 Aurimas Cernius
+ * Copyright (C) 2017,2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,14 +31,14 @@
namespace sharp {
- DateTime XmlConvert::to_date_time(const Glib::ustring & date)
+ Glib::DateTime XmlConvert::to_date_time(const Glib::ustring & date)
{
- return DateTime::from_iso8601(date);
+ return date_time_from_iso8601(date);
}
- Glib::ustring XmlConvert::to_string(const DateTime & date)
+ Glib::ustring XmlConvert::to_string(const Glib::DateTime & date)
{
- return date.to_iso8601();
+ return date_time_to_iso8601(date);
}
}
diff --git a/src/sharp/xmlconvert.hpp b/src/sharp/xmlconvert.hpp
index 336112cb..4cc40148 100644
--- a/src/sharp/xmlconvert.hpp
+++ b/src/sharp/xmlconvert.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2017 Aurimas Cernius
+ * Copyright (C) 2017,2020 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -38,8 +38,8 @@ namespace sharp {
class XmlConvert
{
public:
- static DateTime to_date_time(const Glib::ustring & date);
- static Glib::ustring to_string(const DateTime & date);
+ static Glib::DateTime to_date_time(const Glib::ustring & date);
+ static Glib::ustring to_string(const Glib::DateTime & date);
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]