diff options
author | Joris | 2022-03-19 22:03:58 +0100 |
---|---|---|
committer | Joris | 2022-03-19 22:03:58 +0100 |
commit | 35cc74578e969bae4812afd2ff041eba3746142d (patch) | |
tree | c0ef18d3c81554f0e70c91fcb1006d587470365c /src/validation | |
parent | 199624dc03ead28ddc7454147457512d9568c593 (diff) |
Allow to repeat an event until a specific date
Also provide a shortcut to modify a repetead event from a specific
occurence. This set the end repetition date under the hood and create a
new repeated event.
Diffstat (limited to 'src/validation')
-rw-r--r-- | src/validation/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/validation/mod.rs b/src/validation/mod.rs new file mode 100644 index 0000000..07a7c4c --- /dev/null +++ b/src/validation/mod.rs @@ -0,0 +1,21 @@ +use chrono::NaiveTime; + +use crate::model::time; + +pub fn time(time: String) -> Option<Option<NaiveTime>> { + let time = time.trim(); + if time.is_empty() { + Some(None) + } else { + time::parse(time).map(Some) + } +} + +pub fn non_empty(str: String) -> Option<String> { + let str = str.trim(); + if str.is_empty() { + None + } else { + Some(str.to_string()) + } +} |