Use RFC2822 date formatting in `log`, `tag`, and `record --timestamp`

[?]
7qFsmcJTAmyi5DxiNk265yTyKeTGNeoqjQfzksWAeGkH
Nov 7, 2022, 4:18 AM
BPCAJCLTVK2GVWYURWJTPQ6XA34JUJZNZHG6ONX4ARM3QPJJ6UPQC

Dependencies

  • [2] 3FTEGCMR add timestamp_validator to tag --timestamp option
  • [3] F2S6XETO Fixing log --hash-only
  • [4] E6IKUIPD Command to delete a tag
  • [5] QL6K2ZM3 Tags
  • [6] 4H2XTVJ2 Fix some mistakes in the docs
  • [7] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [8] OU6JOR3C Add path filtering for log, add json output for log
  • [9] GUL4M5FI Cleanup and formatting
  • [10] NS36CJCO Validating timestamps in record

Change contents

  • replacement in pijul/src/commands/tag.rs at line 4
    [4.150][2.0:50]()
    use crate::commands::record::timestamp_validator;
    [4.150]
    [4.150]
    use crate::commands::record::parse_datetime_rfc2822;
  • replacement in pijul/src/commands/tag.rs at line 42
    [4.1086][2.51:120]()
    #[clap(long = "timestamp", validator = timestamp_validator)]
    [4.1086]
    [4.1122]
    #[clap(long = "timestamp", value_parser = parse_datetime_rfc2822)]
  • replacement in pijul/src/commands/record.rs at line 37
    [4.863][4.0:65]()
    #[clap(long = "timestamp", validator = timestamp_validator)]
    [4.863]
    [4.102495]
    #[clap(long = "timestamp", value_parser = parse_datetime_rfc2822)]
  • replacement in pijul/src/commands/record.rs at line 52
    [4.102760][2.121:194](),[2.194][4.128:230](),[4.128][4.128:230](),[4.230][4.314:341](),[4.341][4.256:266](),[4.256][4.256:266]()
    pub(crate) fn timestamp_validator(s: &str) -> Result<(), &'static str> {
    if let Ok(t) = s.parse() {
    if chrono::NaiveDateTime::from_timestamp_opt(t, 0).is_some() {
    return Ok(());
    }
    [4.102760]
    [4.266]
    pub(crate) fn parse_datetime_rfc2822(s: &str) -> Result<i64, &'static str> {
    if let Ok(ts) = chrono::DateTime::parse_from_rfc2822(s) {
    return Ok(ts.timestamp())
  • replacement in pijul/src/commands/log.rs at line 236
    [3.1636][3.1636:1693]()
    writeln!(f, "Date: {}", timestamp)?;
    [3.1636]
    [3.1693]
    writeln!(f, "Date: {}", timestamp.to_rfc2822())?;