Coder Social home page Coder Social logo

jacobdlewis / cal Goto Github PK

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

My Ruby implementation of the Unix program Cal. The program takes a year and month from the user and returns a formatted calendar representation of that month/year combination. The program accounts for date oddities like leap years.

License: MIT License

Ruby 100.00%

cal's Introduction

cal

My Ruby implementation of the Unix program Cal. The program takes a year and month from the user and returns a formatted calendar representation of that month/year combination. The program accounts for date oddities like leap years.

How it Works

A user runs the program by inputting its name and two arguments, month and year (MM/YYYY).

./cal.rb 10/2015

outputs:

         October 2015
    Su Mo Tu We Th Fr Sa
                 1  2  3
     4  5  6  7  8  9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31

A user can also see the calendar for a full year by inputting the program name an only a year (YYYY).

./cal.rb 2015 outputs:

                                 2015

          January               February               March
    Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                 1  2  3   1  2  3  4  5  6  7   1  2  3  4  5  6  7
     4  5  6  7  8  9 10   8  9 10 11 12 13 14   8  9 10 11 12 13 14
    11 12 13 14 15 16 17  15 16 17 18 19 20 21  15 16 17 18 19 20 21
    18 19 20 21 22 23 24  22 23 24 25 26 27 28  22 23 24 25 26 27 28
    25 26 27 28 29 30 31                        29 30 31
                                                
           April                  May                   June
    Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
              1  2  3  4                  1  2      1  2  3  4  5  6
     5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13
    12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20
    19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27
    26 27 28 29 30        24 25 26 27 28 29 30  28 29 30
                          31                    
            July                 August              September
    Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
              1  2  3  4                     1         1  2  3  4  5
     5  6  7  8  9 10 11   2  3  4  5  6  7  8   6  7  8  9 10 11 12
    12 13 14 15 16 17 18   9 10 11 12 13 14 15  13 14 15 16 17 18 19
    19 20 21 22 23 24 25  16 17 18 19 20 21 22  20 21 22 23 24 25 26
    26 27 28 29 30 31     23 24 25 26 27 28 29  27 28 29 30
                          30 31                 
          October               November              December
    Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
                 1  2  3   1  2  3  4  5  6  7         1  2  3  4  5
     4  5  6  7  8  9 10   8  9 10 11 12 13 14   6  7  8  9 10 11 12
    11 12 13 14 15 16 17  15 16 17 18 19 20 21  13 14 15 16 17 18 19
    18 19 20 21 22 23 24  22 23 24 25 26 27 28  20 21 22 23 24 25 26
    25 26 27 28 29 30 31  29 30                 27 28 29 30 31

The progam handles the following odd dates/edge cases:

  • regular leap years
  • century/400 year leap years
  • February day count

##Goals

  • Practice with Arrays, Hashes, and Strings
  • Develop the logic of a non-trivial algorithm
  • Programming to meet a (changing) specification

cal's People

Contributors

jacobdlewis avatar

Watchers

 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.