Skip to content

ryyst/since

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Since

Since what?

14:30:29 risto@GALACTICA /home/risto>
↪ since 13:00
1 hours, 30 minutes, 29 seconds

Install with Cargo:

cargo install since

Now you should have the binary in ~/.cargo/bin/since (on Linux systems).

Semantic CLI utility for calculating time differences

↪ since -h
since v1.0.1

Fetch time difference between <from> and <to>.

If no parameters are given, will return time since UNIX epoch.
Missing <to> argument will always default to current datetime.
All subcommands share exactly the same functionality and arguments as base
command, just filtering the output to different format.

All values are generally rounded down.

USAGE:
    since [ARGS]
    since <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <from>    Start time or date.
    <to>      End time or date, for custom range. Default is current datetime.

SUBCOMMANDS:
    years      Print the output in years (approx)
    months     Print the output in months (approx)
    weeks      Print the output in weeks (approx)
    days       Print the output in days
    hours      Print the output in hours
    minutes    Print the output in minutes
    seconds    Print the output in seconds

Supported date & time formats

All formats are hard-coded and chosen with the loose criteria of "what makes sense", the goal is to be intuitive, not exhaustive (yet).

Time

  • HH:MM
  • HH:MM:SS

Date

  • YYYY-MM-DD
  • YYYY/MM/DD
  • YYYY.MM.DD
  • DD-MM-YYYY
  • DD/MM/YYYY
  • DD.MM.YYYY
  • "DD MONTH YYYY" (eg. Dec or December)
  • "YYYY MONTH DD"

Datetime

  • "[date] [time]"
  • [date]T[time]

Notes on functionality

  • In spite of holy UI semantics, future values are also supported. All values are always absolute distances, thus no negative values should ever appear.
  • The default output shows all applicable time units (years, months, days, hours, minutes, seconds)
  • All calculations are done in the local system's timezone
  • Space-separated parameters must always be wrapped in quotes
  • All naive times (eg. 12:15) are interpreted as "today"
  • All naive dates (eg. 24.12.2019) are interpreted as start of day (00:00:00)
  • Month calculations handle edge cases: if a month doesn't have the start day (e.g., Jan 31 → Feb 31 doesn't exist), that month isn't counted as complete
  • Leap years and DST transitions are handled correctly

Examples

↪ date
Mon 13.10.2025 14:46:54 +0300

# The original usecase, human-readable time calculation with all applicable time units
↪ since 7:00
7 hours, 46 minutes, 54 seconds

↪ since 24.12.2019
5 years, 9 months, 19 days, 14 hours, 46 minutes, 54 seconds

↪ since "1.2.2019 02:30"
6 years, 8 months, 12 days, 12 hours, 16 minutes, 54 seconds

# Explicit time output formats (single unit)
↪ since hours 7:00
7

↪ since minutes 7:00
466

↪ since days 7:00
0

↪ since days 24.12.2019
2120

↪ since months 24.12.2019
69

↪ since years 24.12.2002
22

# Custom time ranges with explicit second parameter
↪ since minutes 14:00 23:45
585

↪ since "1 January 2020" "1 March 2020"
2 months

# Mixing parameter formats
↪ since days "24 December 2019 18:15:30" 2020-6-20
178

# Unix epochs
↪ since
1760356014

↪ since minutes
29339266

↪ since years
55

Build

git clone https://github.com/ryyst/since.git
cd since
cargo build --release

Now you can find the binary in ./target/release/since

Todo

  • A flag for decimal output
  • Timezone support (currently uses local timezone only)

About

Small CLI utility to calculate time differences, with semantic UI for humans

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages