Code Monkey home page Code Monkey logo

shell_clock's Introduction

Clock in the shell

Description

A graphical representation of an anlog clock in the terminal. This repository exists purely as a fun exercise.

Setup

After downloading or cloning this repository and navigating into the repository folder: To execute the program run node index.js. You can optionally provide a timestring in the format "hh:mm" or "h:mm". When no timestring is provided the clock renders the current system time.

To run the tests first install the testing dependencies with the command npm i. Once you have installed the dependencies you can run the tests with npm run test.

Project Logic Requirements

  • the project must render in the console a representation of an analog clock face indicating the time from a provided timestring
  • shows a 'h' in the position where the hour hand of the clock would be
  • shows a 'm' in the position where the minute hand would be
  • shows a 'x' when the hand and minute are in the same position
  • shows a 'o' in the positions where neither the hour nor minute hand of the clock would be
  • a timestring must be provided in the format "h:mm" or "hh:mm"
  • the minute hand is rounded down. For example 21:44 is rounded down to 21:40

Examples

Input: 8:13 Output:

8:13

          o
    o           o

 o                 m

o         +         o

 h                 o

    o           o
          o

Input: 19:39 Output:

19:39

          o
    o           o

 o                 o

o         +         o

 o                 o

    x           o
          o

Input: x:1 Output:

"x:1" is not a valid time
  hours: "x" is not an integer
  mintes: "1" is ambiguous

Input: -1:60 Output:

"-1:60" is not a valid time
  hours: "-1" can not be smaller than 0
  mintes: "60" can not be greater than 59

shell_clock's People

Contributors

noweverywhere 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.