Giter Site home page Giter Site logo

unixtime's Introduction

unixtime

Rust

A small utility for working with UNIX time.

Motivation

Sometimes I need the current unix-time for interacting with APIs and other stuff. But I never remember the correct command for it (it's date +%s). I mostly end up googling the current unix-time. Late at night, I quickly built the original version of this tool. Maybe someone is having the same issue.

Features

  • Printing the current UNIX timestamp in seconds, milliseconds or nanoseconds
  • Reverse conversion of UNIX timestamp to human readable format (RFC 2822, RFC 3339)

As it's using chrono as date and time library this should also work on Windows and other systems not having the date command.

Installation

Download a prebuilt binary

macOS

Install unixtime with the homebrew package manager:

brew tap schoenenberg/tap
brew install unixtime

cargo package manager

unixtime can be installed using the Rust package manager cargo:

cargo install unixtime

Then you should be able to launch unixtime.

Benchmark

Benchmarks were executed with the hyperfine utility:

$> hyperfine 'date +%s' 'unixtime' --warmup 50
Benchmark #1: date +%s
  Time (mean ± σ):       1.5 ms ±   0.6 ms    [User: 0.5 ms, System: 0.6 ms]
  Range (min … max):     0.9 ms …   5.5 ms    626 runs
 
  Warning: Command took less than 5 ms to complete. Results might be inaccurate.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark #2: unixtime
  Time (mean ± σ):       2.7 ms ±   0.7 ms    [User: 0.9 ms, System: 0.6 ms]
  Range (min … max):     2.0 ms …   6.4 ms    476 runs
 
  Warning: Command took less than 5 ms to complete. Results might be inaccurate.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Summary
  'date +%s' ran
    1.79 ± 0.85 times faster than 'unixtime'

unixtime's People

Contributors

mglolenstine avatar schoenenberg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

unixtime's Issues

Reverse unixtime

Hey, here a small feature request.

I recently wanted to get unixtime's into a usual date format (like RFC 3339).

In date I do:

$ date --date=@1458647617
Tue Mar 22 11:53:37 AM UTC 2016

But I often forget it, and I think it's a nice addition to your unixtime binary.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.