Convert timestamps to local times

Related tags

Date and time rizzy
Overview

rizzy

All in a tizzy over timestamps? rizzy is a UNIX filter that will convert UTC timestamps into the timestamp of your choosing.

Example

Before:

$ cat some.log.file
2021-09-17 17:28:07+0000 INFO Running on slurm - limited math CPU usage by a SLURM_CPUS_ON_NODE of 3
2021-09-17 17:30:12+0000 INFO Initializing Environment. Using Environment.V5_C_PROD

After:

$ cat some.log.file | rizzy --chi
2021-09-17T12:28:07-05:00 INFO Running on slurm - limited math CPU usage by a SLURM_CPUS_ON_NODE of 3
2021-09-17T12:30:12-05:00 INFO Initializing Environment. Using Environment.V5_C_PROD

Flags

Running rizzy --help gives more information, but basically:

  • use --chi for Chicago and --nyc for New York
  • for other zones use --zone ...
  • To output in other formats than RFC3339 use --format
  • To optionally treat big numbers encountered as nanos-since-epoch, use --convert-epoch-nanos

Building and running

  • Grab rustup - either from the website or by sudo snap install rustup --classic.
  • Install the stable rust version: rustup install stable
  • Build the code with cargo build, or run with cargo run
Comments
  • Bugfix: negative epochs crash

    Bugfix: negative epochs crash

    • Fix 1: A parsing error means we just keep the original number around.

    (This is just a suggestion, and the maintainers might prefer an alternative solution.)

    • Fix 2: Use signed 64 big to get a tiny bit more range.

    Since the regex is looking for 19 digits only, this will fix the issue, as 2^63 has 19 digits but 2^64 has 20 digits. Thus with the range up to 2^64, we're in the clear.


    EDIT: The above was auto-generated with the Github CLI.

    Question to @mattgodbolt (and maintainers): What is the behavior you'd like to see?

    Fixes: https://github.com/aquanauts/rizzy/issues/2

    opened by siedentop 6
  • Timezones: Build auto-suggestion from all known timezones.

    Timezones: Build auto-suggestion from all known timezones.

    Proof of concept for #9.

    chris@christophs-air rizzy % cargo run -- -z America/Chi
        Finished dev [unoptimized + debuginfo] target(s) in 0.07s
         Running `target/debug/rizzy -z America/Chi`
    Error: 
       0: Unknown timezone 'America/Chi', did you mean: ["America/Chihuahua", "America/Chicago"]
    
    Location:
       src/main.rs:103
    
    Backtrace omitted.
    Run with RUST_BACKTRACE=1 environment variable to display it.
    Run with RUST_BACKTRACE=full to include source snippets.
    
    opened by siedentop 2
  • Fix crash caused by unusual digit (number character).

    Fix crash caused by unusual digit (number character).

    • I found this using fuzzing.
    • I'm not sure if the output makes any sense, but I feel like this is better than just crashing. Others may disagree.

    I'm happy to provide the fuzzing code as well. Link: https://github.com/siedentop/rizzy/pull/new/fuzzing/trying-fuzzing Please let me know if you want a PR for that. (I kinda suspect that this fuzzing code is not terribly useful.)

    opened by siedentop 1
  • Rust Format

    Rust Format

    I took the liberty to run Rust Format on everything -- if you're not ready for this yet, I totally understand.

    Note: I did not have a chance to test the Github Action. Let's see how it works.

    UPDATE: The Github Action works: https://github.com/siedentop/rizzy/actions/runs/1770883233 UPDATE 2: And here is the GH Action failing, if the code is not formatted correctly: https://github.com/siedentop/rizzy/runs/5001466217?check_suite_focus=true

    Reference: #5

    opened by siedentop 1
  • rizzy -n doesn't handle large negative value

    rizzy -n doesn't handle large negative value

    % echo '-9223372036854775808' | rizzy -n
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', src/rizzy.rs:77:69
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    % echo '-9223372036854775807' | rizzy -n
    -2262-04-11T17:47:16.854775807-06:00
    % rizzy --version
    rizzy 0.1.1
    
    opened by jordansamuels 1
  • Support `cat` like ability - read files from arguments

    Support `cat` like ability - read files from arguments

    I keep finding I want to do: rizzy somefile.txt but discover of course I need to cat somefile.txt | rizzy. But it seems like that'd be a nice thing to support (arbitrary number of files in fact).

    enhancement 
    opened by mattgodbolt 0
  • Rust Format

    Rust Format

    Thanks for this neat little utility!

    Would it be possible for you to run Rust Format (rustfmt) on the code. This would make it more fun to contribute to your code.

    If you prefer, you could enforce future compliance through the GitHub Actions.

    This example suggests doing it this way:

          - uses: actions-rs/cargo@v1
            with:
              command: fmt
              args: --all -- --check
    
    opened by siedentop 0
  • Consider building statically

    Consider building statically

    We use rizzy as an easy-copyable binary at Aquatic. That works as we all agree on the Ubuntu version:

    $ ldd target/release/rizzy
    	linux-vdso.so.1 (0x00007ffd83470000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f040597e000)
    	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0405776000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0405557000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0405353000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0404f62000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f04061cf000)
    

    It might be worth looking at building a musl static build which ends up with a 7MB static binary.

    $ rustup target add x86_64-unknown-linux-musl
    $ cargo build --release --target x86_64-unknown-linux-musl
    $ ls -hld target/x86_64-unknown-linux-musl/release/rizzy
    -rwxrwxr-x 2 mgodbolt mgodbolt 7.0M Feb  3 19:27 target/x86_64-unknown-linux-musl/release/rizzy
    $ ldd target/x86_64-unknown-linux-musl/release/rizzy
    	not a dynamic executable
    
    opened by mattgodbolt 0
  • Better `panic` handling

    Better `panic` handling

    I'm not sure what the rust-y way to do this is but when I typo a timezone, this seems pretty nasty:

    $ rizzy --zone not_a_tz
    thread 'main' panicked at 'Could not parse timezone: not_a_tz, Error: 'not_a_tz' is not a valid timezone', src/main.rs:45:19
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    enhancement 
    opened by mattgodbolt 5
  • Unbounded memory

    Unbounded memory

    Cool tool!

    One thing caught my eye: https://github.com/aquanauts/rizzy/blob/c98251b16fe13dd0b1c6054c9d24c3a3454cb06a/src/main.rs#L67

    If you are processing a stream without newlines that is going to eat all the RAM. It would be wise to do a few KB at a time in a buffer.

    https://github.com/uutils/coreutils/blob/master/src/uu/wc/src/count_fast.rs#L31 has the boilerplate tuned for Linux system calls.

    enhancement 
    opened by chadbrewbaker 1
Releases(v0.1.5)
Owner
Aquatic Capital Management
Building the world's best prediction machine
Aquatic Capital Management
Fast abstraction for converting human-like times into milliseconds.

MS converter library Fast abstraction for converting human-like times into milliseconds. Like, are 1d to 86400000. There are two ways to calculate mil

Mikhail Panfilov 31 Nov 7, 2022
datez: convert a time into several timezones

datez: convert a time into several timezones In July, when it is 16:00 in Canberra, what time is it in Caracas, and where I am in Cambridge? $ datez 2

Tony Finch 7 Nov 17, 2021
A command-line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the returned URL.

Pup A command line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the return

SteveLau 11 Aug 17, 2022
Plugin for macro-, mini-quad (quads) to save data in simple local storage using Web Storage API in WASM and local file on a native platforms.

quad-storage This is the crate to save data in persistent local storage in miniquad/macroquad environment. In WASM the data persists even if tab or br

ilya sheprut 9 Jan 4, 2023
Used to generate and compare bounded timestamps.

ClockBound Summary: ClockBound allows you to generate and compare bounded timestamps that include accumulated error as reported from the local chronyd

Amazon Web Services 149 Nov 28, 2022
Cover your tracks during Linux Exploitation by leaving zero traces on system logs and filesystem timestamps. 👻🐚

moonwalk Cover your tracks during Linux Exploitation / Penetration Testing by leaving zero traces on system logs and filesystem timestamps. ?? Table o

Mufeed VH 1.1k Jan 6, 2023
This crate provides high-performance formatting and parsing routines for ISO8061 timestamps

ISO8061 Timestamp This crate provides high-performance formatting and parsing routines for ISO8061 timestamps, primarily focused on UTC values but wit

Lantern 4 Sep 21, 2022
Rust crate implementing short & stable ids based on timestamps

Lexicoid Short & stable IDs based on timestamps. Heavily inspired by Short, friendly base32 slugs from timestamps by @brandur. Install Install with ca

Luciano Mammino 6 Jan 29, 2023
Cover your tracks during Linux Exploitation by leaving zero traces on system logs and filesystem timestamps.

moonwalk-back Cover your tracks during Linux Exploitation / Penetration Testing by leaving zero traces on system logs and filesystem timestamps. ?? Ta

Aditya 57 Nov 24, 2024
Convert local CAN log files to "routes" suitable for Cabana

Make Cabana Route Utility that takes CSV formatted CAN log files and (optionally) accompanying videos, convert them to "routes" that can be opened in

Angus Gratton 3 Oct 23, 2023
Fast abstraction for converting human-like times into milliseconds.

MS converter library Fast abstraction for converting human-like times into milliseconds. Like, are 1d to 86400000. There are two ways to calculate mil

Mikhail Panfilov 31 Nov 7, 2022
Library + CLI-Tool to measure the TTFB (time to first byte) of HTTP requests. Additionally, this crate measures the times of DNS lookup, TCP connect and TLS handshake.

TTFB: CLI + Lib to Measure the TTFB of HTTP/1.1 Requests Similar to the network tab in Google Chrome or Mozilla Firefox, this crate helps you find the

Philipp Schuster 24 Dec 1, 2022
atttribute macro for running a flaky test multiple times

flaky_test This attribute macro will register and run a test 3 times, erroring only if all three times fail. Useful for situations when a test is flak

Deno Land 23 Mar 23, 2022
Make any NixOS system netbootable with 10s cycle times.

nix-netboot-serve Dynamically generate netboot images for arbitrary NixOS system closures, profiles, or configurations with 10s iteration times. Usage

Determinate Systems 152 Dec 24, 2022
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

Zeke Medley 7 Oct 3, 2022
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

zeke 7 Oct 3, 2022
Fake ping times.

Pong A Linux program that replies to ping but modifies the payload of the ICMP package to get lower ping times in some ping implementations. See https

Mara Bos 136 Sep 21, 2022
Showcase for pathological compile times when using knuffel / chumsky / VERY LARGE types

netherquote Showcase for pathological compile times when using knuffel / chumsky / VERY LARGE types. How to reproduce The rust toolchain version is pi

Amos Wenger 7 Jan 1, 2023
Utility to inherit dependencies from workspace file if it occurs 'n' or more times throughout the project.

Cargo Workspace Dependency Inheritor Utility that inherits dependencies from the main workspace if they occur n or more times in the workspace. Worksp

Timon 9 Oct 14, 2022
Code for blog post "{n} times faster than C, where n = 128"

Code for {n} times faster than C, where n = 128 Actually, n = 290 ?? Benchmark Setup Rust version: rustc 1.70.0 (90c541806 2023-05-31) Run test: cargo

Thomas Ip 9 Jul 24, 2023