about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xCargo.lock64
-rwxr-xr-xCargo.toml19
-rwxr-xr-xsrc/ui/task_details.rs4
-rwxr-xr-xsrc/ui/tasks_page.rs19
4 files changed, 91 insertions, 15 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 66fa5c3..61c71af 100755
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -138,6 +138,21 @@ dependencies = [
 ]
 
 [[package]]
+name = "chrono_locale"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cbf42d590cf2cd03df7910ef6e1cd46039ca566d0547341a3f9b6bfd9e3c491"
+dependencies = [
+ "chrono",
+ "lazy_static",
+ "num-integer",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "walkdir",
+]
+
+[[package]]
 name = "clap"
 version = "2.34.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -160,7 +175,7 @@ checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
 dependencies = [
  "bstr",
  "csv-core",
- "itoa",
+ "itoa 0.4.8",
  "ryu",
  "serde",
 ]
@@ -250,6 +265,7 @@ version = "1.5.0"
 dependencies = [
  "anyhow",
  "chrono",
+ "chrono_locale",
  "csv",
  "dbus",
  "dbus-codegen",
@@ -655,6 +671,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
 
 [[package]]
+name = "itoa"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
+
+[[package]]
 name = "lazy_static"
 version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1020,6 +1042,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
 
 [[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
 name = "semver"
 version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1058,6 +1089,17 @@ dependencies = [
 ]
 
 [[package]]
+name = "serde_json"
+version = "1.0.81"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
+dependencies = [
+ "itoa 1.0.2",
+ "ryu",
+ "serde",
+]
+
+[[package]]
 name = "slab"
 version = "0.4.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1196,6 +1238,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
 
 [[package]]
+name = "walkdir"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
+dependencies = [
+ "same-file",
+ "winapi",
+ "winapi-util",
+]
+
+[[package]]
 name = "wasi"
 version = "0.10.2+wasi-snapshot-preview1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1218,6 +1271,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
 
 [[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
 name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index bc92550..c4b2bf8 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,21 +5,22 @@ authors = ["Ricky Kresslein <rk@lakoliu.com>"]
 edition = "2018"
 
 [dependencies]
-gettext-rs = { version = "0.7", features = ["gettext-system"] }
-rusqlite = "0.27.0"
+anyhow = "1.0"
 chrono = { version = "0.4", features = ["unstable-locales"] }
-directories = "4.0"
-once_cell = "1.12.0"
+chrono_locale = "0.1"
+csv = "1.1.6"
 dbus = "0.9.5"
 dbus-codegen = "0.10.0"
-log = "0.4"
+directories = "4.0"
+gettext-rs = { version = "0.7", features = ["gettext-system"] }
 gtk4-macros = "0.4.8"
 itertools = "0.10.3"
-anyhow = "1.0"
-serde = { version = "1.0", features = ["derive"] }
-csv = "1.1.6"
-num-traits = "0.2.14"
+log = "0.4"
 num-derive = "0.3.3"
+num-traits = "0.2.14"
+once_cell = "1.12.0"
+rusqlite = "0.27.0"
+serde = { version = "1.0", features = ["derive"] }
 
 [dependencies.gtk]
 package = "gtk4"
diff --git a/src/ui/task_details.rs b/src/ui/task_details.rs
index b8771ac..51dab22 100755
--- a/src/ui/task_details.rs
+++ b/src/ui/task_details.rs
@@ -206,9 +206,9 @@ impl FurTaskDetails {
                 stop_time_edit.set_text(&stop_time_w_year);
 
                 let instructions = gtk::Label::new(Some(
-                    &gettext("*Use your local format XX/XX/XX HH:MM:SS")));
+                    &gettext("*Use the format MM/DD/YY HH:MM:SS")));
                 if !settings_manager::get_bool("show-seconds") {
-                    instructions.set_text(&gettext("*Use your local format XX/XX/XX HH:MM"));
+                    instructions.set_text(&gettext("*Use the format MM/DD/YY HH:MM"));
                 }
                 instructions.set_visible(false);
                 instructions.add_css_class("error_message");
diff --git a/src/ui/tasks_page.rs b/src/ui/tasks_page.rs
index 911b005..192a309 100755
--- a/src/ui/tasks_page.rs
+++ b/src/ui/tasks_page.rs
@@ -17,9 +17,11 @@
 use adw::prelude::{PreferencesGroupExt, PreferencesPageExt};
 use adw::subclass::prelude::*;
 use chrono::{DateTime, Duration, Local};
+use chrono_locale::LocaleDate;
 use gettextrs::*;
 use gtk::subclass::prelude::*;
 use gtk::{glib, prelude::*};
+use std::env;
 
 use crate::database::{self, SortOrder, TaskSort};
 use crate::settings_manager;
@@ -87,6 +89,17 @@ impl FurTasksPage {
     pub fn build_task_list(&self) {
         let imp = imp::FurTasksPage::from_instance(&self);
 
+        // Get user's locale for date formatting
+        let locale_env = env::var("LANG");
+        let user_locale: String;
+        if let Err(_) = locale_env {
+            user_locale = "en_US".to_string();
+        } else {
+            let locale_env = locale_env.unwrap();
+            let split_locale: Vec<&str> = locale_env.split(".").collect();
+            user_locale = split_locale[0].to_string();
+        }
+
         let tasks_list = database::retrieve(TaskSort::StartTime, SortOrder::Descending).unwrap();
 
         let mut uniq_date_list: Vec<String> = Vec::new();
@@ -99,7 +112,7 @@ impl FurTasksPage {
         for task in tasks_list {
             let task_clone = task.clone();
             let date = DateTime::parse_from_rfc3339(&task.start_time).unwrap();
-            let date = date.format("%h %e").to_string();
+            let date = date.formatl("%h %e", &user_locale).to_string();
             if !uniq_date_list.contains(&date) {
                 // if same_date_list is empty, push "date" to it
                 // if it is not empty, push it to a vec of vecs, and then clear it
@@ -135,8 +148,8 @@ impl FurTasksPage {
         // Create FurTasksGroups for all unique days
         let now = Local::now();
         let yesterday = now - Duration::days(1);
-        let yesterday = yesterday.format("%h %e").to_string();
-        let today = now.format("%h %e").to_string();
+        let yesterday = yesterday.formatl("%h %e", &user_locale).to_string();
+        let today = now.formatl("%h %e", &user_locale).to_string();
         for i in 0..uniq_date_list.len() {
             let group = FurTasksGroup::new();
             if uniq_date_list[i] == today {