Skip to content

Commit 36bc2f3

Browse files
authored
changing timestamp-utility functions to pub (#614)
* changing timestamp-utility functions to pub As suggested in issue #613, I've moved the timestamp utilities public. Also physically moved the functions outside the comment for utility functions for clarity. Will allow the same functionality to be used for other timestamp data in the task, such as `scheduled`. * Add documentation comments
1 parent 8809854 commit 36bc2f3

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/task/task.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,11 @@ impl Task {
546546
self.set_value(key, None, ops)
547547
}
548548

549-
// -- utility functions
550-
551-
fn is_known_key(key: &str) -> bool {
552-
Prop::from_str(key).is_ok()
553-
|| key.starts_with("tag_")
554-
|| key.starts_with("annotation_")
555-
|| key.starts_with("dep_")
556-
}
557-
558-
fn get_timestamp(&self, property: &str) -> Option<Timestamp> {
549+
/// Get the given timestamp property.
550+
///
551+
/// This will return `None` if the property is not set, or if it is not a valid
552+
/// timestamp. Otherwise, a correctly parsed Timestamp is returned.
553+
pub fn get_timestamp(&self, property: &str) -> Option<Timestamp> {
559554
if let Some(ts) = self.data.get(property) {
560555
if let Ok(ts) = ts.parse() {
561556
return Some(utc_timestamp(ts));
@@ -565,14 +560,24 @@ impl Task {
565560
None
566561
}
567562

568-
fn set_timestamp(
563+
/// Set the given timestamp property, mapping the value correctly.
564+
pub fn set_timestamp(
569565
&mut self,
570566
property: &str,
571567
value: Option<Timestamp>,
572568
ops: &mut Operations,
573569
) -> Result<()> {
574570
self.set_value(property, value.map(|v| v.timestamp().to_string()), ops)
575571
}
572+
573+
// -- utility functions
574+
575+
fn is_known_key(key: &str) -> bool {
576+
Prop::from_str(key).is_ok()
577+
|| key.starts_with("tag_")
578+
|| key.starts_with("annotation_")
579+
|| key.starts_with("dep_")
580+
}
576581
}
577582

578583
#[cfg(test)]

0 commit comments

Comments
 (0)