Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.3.2 - TBD
- Fixed handling of unicode characters immediately adjacent to timestamps

## 0.3.1 - 2025-12-03
- Add pre-built binaries to the release artifacts

Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
info@nautechsystems.io.
support@databento.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "epoch-to"
authors = ["Databento <support@databento.com>"]
version = "0.3.1"
version = "0.3.2"
edition = "2021"
repository = "https://github.com/databento/epoch"
description = "CLI tool for converting UNIX timestamps to human-readable date strings"
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl Reformatter {
// isn't a number, so print it as `text_after`
let (number_end, text_after) = text_iter
.find(|(_, c)| !NUMBERS.contains(c))
.map(|(i, _)| (i, &line[i..i + 1]))
// len_utf8 to handle multi-byte chars
.map(|(i, c)| (i, &line[i..i + c.len_utf8()]))
.unwrap_or_else(|| (line.len(), ""));

// If the length of the number is less than that of the lower second bound, can skip parsing
Expand Down Expand Up @@ -110,8 +111,8 @@ impl Reformatter {
continue;
}
}
// plus 1 for text_after
let text = &line[text_start..(number_end + 1).min(line.len())];
// plus text_after length (which may be multi-byte)
let text = &line[text_start..(number_end + text_after.len()).min(line.len())];
write!(writer, "{text}",)?;
}
Ok(())
Expand Down
6 changes: 4 additions & 2 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use assert_cmd::Command;
use assert_cmd::{cargo::cargo_bin_cmd, Command};
use predicates::{
boolean::PredicateBooleanExt,
ord::eq,
Expand All @@ -7,7 +7,7 @@ use predicates::{
use rstest::*;

fn cmd() -> Command {
Command::cargo_bin("epoch").unwrap()
cargo_bin_cmd!("epoch")
}

#[rstest]
Expand All @@ -23,6 +23,8 @@ fn cmd() -> Command {
"Deserializationµs=547.261 1709152989",
"Deserializationµs=547.261 2024-02-28T20:43:09Z"
)]
#[case::symbol_adjacent("€1709152989¥", "€2024-02-28T20:43:09Z¥")]
#[case::symbol_adjacent("東京1709152989서울", "東京2024-02-28T20:43:09Z서울")]
fn test_replacement(#[case] stdin: &str, #[case] stdout: &str) {
cmd()
.write_stdin(format!("{stdin}\n"))
Expand Down