about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicky Kresslein <rk@lakoliu.com>2022-06-07 18:44:38 +0300
committerRicky Kresslein <rk@lakoliu.com>2022-06-07 18:44:53 +0300
commit67679138574b083d838294bf82b6058a54b6a13d (patch)
treedecc40525f13d0ae9bbbe9345e40ca89102a0c57
parent52c2769e28e5ada8162526c2f4ab4f596b34a11a (diff)
downloadFurtherance-67679138574b083d838294bf82b6058a54b6a13d.tar.zst
#63 - Can't add task with start later than stop
-rw-r--r--po/Furtherance.pot34
-rwxr-xr-xsrc/ui/window.rs26
2 files changed, 29 insertions, 31 deletions
diff --git a/po/Furtherance.pot b/po/Furtherance.pot
index ea2fd5b..4c36890 100644
--- a/po/Furtherance.pot
+++ b/po/Furtherance.pot
@@ -124,7 +124,7 @@ msgstr ""
 msgid "_Dark theme"
 msgstr ""
 
-#: src/gtk/preferences_window.ui:28 src/ui/window.rs:556
+#: src/gtk/preferences_window.ui:28 src/ui/window.rs:562
 msgid "Idle"
 msgstr ""
 
@@ -306,7 +306,7 @@ msgid "Task Details"
 msgstr ""
 
 #: src/gtk/task_details.ui:96 src/application.rs:287 src/ui/task_details.rs:191
-#: src/ui/window.rs:333 src/ui/window.rs:595
+#: src/ui/window.rs:333 src/ui/window.rs:601
 msgid "Stop"
 msgstr ""
 
@@ -378,16 +378,16 @@ msgstr ""
 msgid "DELETE"
 msgstr ""
 
-#: src/application.rs:264 src/ui/window.rs:559
+#: src/application.rs:264 src/ui/window.rs:565
 msgid "Discard"
 msgstr ""
 
-#: src/application.rs:265 src/application.rs:286 src/ui/window.rs:560
-#: src/ui/window.rs:594
+#: src/application.rs:265 src/application.rs:286 src/ui/window.rs:566
+#: src/ui/window.rs:600
 msgid "Continue"
 msgstr ""
 
-#: src/application.rs:276 src/ui/window.rs:591
+#: src/application.rs:276 src/ui/window.rs:597
 msgid "Time's up!"
 msgstr ""
 
@@ -419,11 +419,11 @@ msgstr ""
 msgid "Edit Task"
 msgstr ""
 
-#: src/ui/task_details.rs:210
+#: src/ui/task_details.rs:210 src/ui/window.rs:355
 msgid "*Use your local format XX/XX/XX HH:MM:SS"
 msgstr ""
 
-#: src/ui/task_details.rs:212
+#: src/ui/task_details.rs:212 src/ui/window.rs:357
 msgid "*Use your local format XX/XX/XX HH:MM"
 msgstr ""
 
@@ -483,36 +483,28 @@ msgstr ""
 msgid "tags"
 msgstr ""
 
-#: src/ui/window.rs:355
-msgid "*Use the format MMM DD YYYY HH:MM:SS"
-msgstr ""
-
-#: src/ui/window.rs:357
-msgid "*Use the format MMM DD YYYY HH:MM"
-msgstr ""
-
 #: src/ui/window.rs:373
 msgid "*Task name cannot be blank."
 msgstr ""
 
-#: src/ui/window.rs:547
+#: src/ui/window.rs:553
 msgid "You have been idle for "
 msgstr ""
 
-#: src/ui/window.rs:548
+#: src/ui/window.rs:554
 msgid ""
 "\n"
 "Would you like to discard that time, or continue the clock?"
 msgstr ""
 
-#: src/ui/window.rs:689
+#: src/ui/window.rs:695
 msgid "Autosave Restored"
 msgstr ""
 
-#: src/ui/window.rs:692
+#: src/ui/window.rs:698
 msgid "Furtherance shut down improperly. An autosave was restored."
 msgstr ""
 
-#: src/ui/window.rs:751
+#: src/ui/window.rs:757
 msgid "Stop the timer to duplicate a task."
 msgstr ""
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 992bc9f..133da09 100755
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -338,13 +338,13 @@ impl FurtheranceWindow {
             let stop_time = Local::now();
             let start_time = stop_time - ChronDur::seconds(1);
 
-            let mut start_time_w_year = start_time.format("%h %d %Y %H:%M:%S").to_string();
+            let mut start_time_w_year = start_time.format("%x %H:%M:%S").to_string();
             if !settings_manager::get_bool("show-seconds") {
-                start_time_w_year = start_time.format("%h %d %Y %H:%M").to_string();
+                start_time_w_year = start_time.format("%x %H:%M").to_string();
             }
-            let mut stop_time_w_year = stop_time.format("%h %d %Y %H:%M:%S").to_string();
+            let mut stop_time_w_year = stop_time.format("%x %H:%M:%S").to_string();
             if !settings_manager::get_bool("show-seconds") {
-                stop_time_w_year = stop_time.format("%h %d %Y %H:%M").to_string();
+                stop_time_w_year = stop_time.format("%x %H:%M").to_string();
             }
             let start_time_edit = gtk::Entry::new();
             start_time_edit.set_text(&start_time_w_year);
@@ -352,9 +352,9 @@ impl FurtheranceWindow {
             stop_time_edit.set_text(&stop_time_w_year);
 
             let instructions = gtk::Label::new(Some(
-                &gettext("*Use the format MMM DD YYYY HH:MM:SS")));
+                &gettext("*Use your local format XX/XX/XX HH:MM:SS")));
             if !settings_manager::get_bool("show-seconds") {
-                instructions.set_text(&gettext("*Use the format MMM DD YYYY HH:MM"));
+                instructions.set_text(&gettext("*Use your local format XX/XX/XX HH:MM"));
             }
             instructions.set_visible(false);
             instructions.add_css_class("error_message");
@@ -410,11 +410,11 @@ impl FurtheranceWindow {
                     if settings_manager::get_bool("show-seconds") {
                         new_start_time = NaiveDateTime::parse_from_str(
                                             &new_start_time_str,
-                                            "%h %d %Y %H:%M:%S");
+                                            "%x %H:%M:%S");
                     } else {
                         new_start_time = NaiveDateTime::parse_from_str(
                                                 &new_start_time_str,
-                                                "%h %d %Y %H:%M");
+                                                "%x %H:%M");
                     }
                     if let Err(_) = new_start_time {
                         instructions.set_visible(true);
@@ -433,11 +433,11 @@ impl FurtheranceWindow {
                     if settings_manager::get_bool("show-seconds") {
                         new_stop_time = NaiveDateTime::parse_from_str(
                                             &new_stop_time_str,
-                                            "%h %d %Y %H:%M:%S");
+                                            "%x %H:%M:%S");
                     } else {
                         new_stop_time = NaiveDateTime::parse_from_str(
                                                 &new_stop_time_str,
-                                                "%h %d %Y %H:%M");
+                                                "%x %H:%M");
                     }
                     if let Err(_) = new_stop_time {
                         instructions.set_visible(true);
@@ -450,6 +450,12 @@ impl FurtheranceWindow {
                         }
                     }
 
+                    // Start time can't be later than stop time
+                    if !do_not_close && (new_stop_time_local - new_start_time_local).num_seconds() < 0 {
+                        time_error.set_visible(true);
+                        do_not_close = true;
+                    }
+
                     // Tags
                     let mut new_tag_list = "".to_string();
                     if !task_tags_edit.text().trim().is_empty() {