Skip to content

Commit

Permalink
Merge pull request #378 from djmitche/update-time
Browse files Browse the repository at this point in the history
Update to the latest chrono and time
  • Loading branch information
djmitche authored Apr 21, 2024
2 parents db4c917 + 148a70b commit 019d189
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 38 deletions.
53 changes: 29 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/tests/update-and-delete-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn update_and_delete_sync(delete_first: bool) -> anyhow::Result<()> {
{
let mut t = rep2.get_task(u)?.unwrap().into_mut(&mut rep2);
t.delete()?;
t.set_modified(Utc.ymd(1980, 1, 1).and_hms(0, 0, 0))?;
t.set_modified(Utc.with_ymd_and_hms(1980, 1, 1, 0, 0, 0).unwrap())?;
}

// sync it back to rep1
Expand Down
2 changes: 1 addition & 1 deletion taskchampion/src/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ mod tests {
t = rep.new_task(Status::Deleted, "goner".into()).unwrap();
{
let mut t = t.into_mut(&mut rep);
t.set_modified(Utc.ymd(1980, 1, 1).and_hms(0, 0, 0))
t.set_modified(Utc.with_ymd_and_hms(1980, 1, 1, 0, 0, 0).unwrap())
.unwrap();
}

Expand Down
24 changes: 12 additions & 12 deletions taskchampion/src/task/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ mod test {

#[test]
fn test_entry_set() {
let ts = Utc.ymd(1980, 1, 1).and_hms(0, 0, 0);
let ts = Utc.with_ymd_and_hms(1980, 1, 1, 0, 0, 0).unwrap();
let task = Task::new(
Uuid::new_v4(),
vec![(String::from("entry"), format!("{}", ts.timestamp()))]
Expand All @@ -654,7 +654,7 @@ mod test {

#[test]
fn test_wait_in_past() {
let ts = Utc.ymd(1970, 1, 1).and_hms(0, 0, 0);
let ts = Utc.with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap();
let task = Task::new(
Uuid::new_v4(),
vec![(String::from("wait"), format!("{}", ts.timestamp()))]
Expand All @@ -669,7 +669,7 @@ mod test {

#[test]
fn test_wait_in_future() {
let ts = Utc.ymd(3000, 1, 1).and_hms(0, 0, 0);
let ts = Utc.with_ymd_and_hms(3000, 1, 1, 0, 0, 0).unwrap();
let task = Task::new(
Uuid::new_v4(),
vec![(String::from("wait"), format!("{}", ts.timestamp()))]
Expand Down Expand Up @@ -757,7 +757,7 @@ mod test {

#[test]
fn test_get_due() {
let test_time = Utc.ymd(2033, 1, 1).and_hms(0, 0, 0);
let test_time = Utc.with_ymd_and_hms(2033, 1, 1, 0, 0, 0).unwrap();
let task = Task::new(
Uuid::new_v4(),
vec![(String::from("due"), format!("{}", test_time.timestamp()))]
Expand All @@ -782,7 +782,7 @@ mod test {

#[test]
fn test_add_due() {
let test_time = Utc.ymd(2033, 1, 1).and_hms(0, 0, 0);
let test_time = Utc.with_ymd_and_hms(2033, 1, 1, 0, 0, 0).unwrap();
with_mut_task(|mut task| {
assert_eq!(task.get_due(), None);
task.set_due(Some(test_time)).unwrap();
Expand All @@ -792,7 +792,7 @@ mod test {

#[test]
fn test_remove_due() {
let test_time = Utc.ymd(2033, 1, 1).and_hms(0, 0, 0);
let test_time = Utc.with_ymd_and_hms(2033, 1, 1, 0, 0, 0).unwrap();
with_mut_task(|mut task| {
task.set_due(Some(test_time)).unwrap();
task.reload().unwrap();
Expand Down Expand Up @@ -835,11 +835,11 @@ mod test {
anns,
vec![
Annotation {
entry: Utc.timestamp(1635301873, 0),
entry: Utc.timestamp_opt(1635301873, 0).unwrap(),
description: "left message".into()
},
Annotation {
entry: Utc.timestamp(1635301883, 0),
entry: Utc.timestamp_opt(1635301883, 0).unwrap(),
description: "left another message".into()
}
]
Expand All @@ -850,7 +850,7 @@ mod test {
fn test_add_annotation() {
with_mut_task(|mut task| {
task.add_annotation(Annotation {
entry: Utc.timestamp(1635301900, 0),
entry: Utc.timestamp_opt(1635301900, 0).unwrap(),
description: "right message".into(),
})
.unwrap();
Expand All @@ -860,7 +860,7 @@ mod test {
assert_eq!(task.taskmap[k], "right message".to_owned());
// adding with same time overwrites..
task.add_annotation(Annotation {
entry: Utc.timestamp(1635301900, 0),
entry: Utc.timestamp_opt(1635301900, 0).unwrap(),
description: "right message 2".into(),
})
.unwrap();
Expand All @@ -876,7 +876,7 @@ mod test {
task.set_string("annotation_1635301883", Some("left another message".into()))
.unwrap();

task.remove_annotation(Utc.timestamp(1635301873, 0))
task.remove_annotation(Utc.timestamp_opt(1635301873, 0).unwrap())
.unwrap();

task.reload().unwrap();
Expand All @@ -886,7 +886,7 @@ mod test {
assert_eq!(
anns,
vec![Annotation {
entry: Utc.timestamp(1635301883, 0),
entry: Utc.timestamp_opt(1635301883, 0).unwrap(),
description: "left another message".into()
}]
);
Expand Down

0 comments on commit 019d189

Please sign in to comment.