Coder Social home page Coder Social logo

jaapie / how-many Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 36 KB

A small Ruby CLI script that answers the question: "How many seconds in a year" and and other time-related queries.

License: MIT License

Ruby 100.00%
ruby cli time units converter

how-many's Introduction

How Many?

how-many is a small Ruby CLI script that answers questions like: "How many seconds are there in a year", and many more.

I created this script so that when I wanted to shutdown -r -t ? a server in 8h and 23 minutes I didn't have to ask Google or Spotlight.

It has a simple, natural language style interface, with some output formatting options. For example:

$ how-many seconds in 1 year
31536025.919999998
$ hay-many weeks in 1 month
4.3452416666666664

The script understands the following time units:

  • seconds
  • minutes
  • hours
  • days
  • weeks
  • fortnights
  • months
  • years

By default, results will be displayed as floating point numbers, however you can pass the -t option (use the -h or --help option for more information) to choose integer, in which case the number is rounded up.

It uses the definition that a year is 52.1429 weeks. There are 24.0072 hours in 0.1429 weeks.

Operations

how-many will understand two operations: in and till. It currently only understands in. That means you can ask it how many of one unit will fit into another. I am implementing the till function next. You will he able to ask:

$how-many seconds till 10pm

or

$how-many days till 2020-02-20

Using the Script

The script is pretty basic in that that is all it is. You just need to copy it to a place on your $PATH so you can use it anywhere, or put it somewhere and call it by prepending ./ (if it is in the current directory) or its path (if it is anywhere else).

I'm not sure how'd you go getting it running on windows, but you could probably find a GUI for what you want anyhow.

Contributing

I welcome comments, criticisms, praise, pointers to tools that already did this, and most of all contributions in the form of pull-requests.

License

This work is distributed under the MIT license as you can read about in the LICENSE.md file.

Author

how-many was written by me, Jacob Degeling, in my spare time. I am a School IT Manager whose first love in the computer world was programming.

:wq

how-many's People

Contributors

jaapie avatar

Watchers

James Cloos avatar  avatar

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.