Code Monkey home page Code Monkey logo

days's Introduction

days

Print some days in a list.

Usage

$ ./days.py  -h

usage: Print a list of days over a given number of weeks. [-h] [-y YEAR]
                                                          [-m MONTH] [-d DAY]
                                                          [-w WEEKS]
                                                          [-s [Weekday [Weekday ...]]]
                                                          [-c]

optional arguments:
  -h, --help            show this help message and exit
  -y YEAR, --year YEAR  Year (default is current year: 2018)
  -m MONTH, --month MONTH
                        Month (default is current month: 1)
  -d DAY, --day DAY     Day (default is current day: 22)
  -w WEEKS, --weeks WEEKS
                        Number of weeks. Default is 14.
  -s [Weekday [Weekday ...]], --dows [Weekday [Weekday ...]]
                        Weekdays we wish to print (e.g. Tue, Thu)
  -c, --chunk           Separate output into chunks based on the number of
                        days specified.

Examples

The default is to print Tuesdays and Thursdays for 14 weeks, starting on the current day. e.g. if run on Jan 22, 2018 with the default arguments:

$ ./days.py
Tue Jan 23
Thu Jan 25
Tue Jan 30
Thu Feb  1
Tue Feb  6
Thu Feb  8
Tue Feb 13
Thu Feb 15
Tue Feb 20
Thu Feb 22
Tue Feb 27
Thu Mar  1
Tue Mar  6
Thu Mar  8
Tue Mar 13
Thu Mar 15
Tue Mar 20
Thu Mar 22
Tue Mar 27
Thu Mar 29
Tue Apr  3
Thu Apr  5
Tue Apr 10
Thu Apr 12
Tue Apr 17
Thu Apr 19
Tue Apr 24
Thu Apr 26

Here, we print 4 weeks of Wednesdays starting on Jan 15, 2018.

$ ./days.py -y 2017 -m 1 -d 15 -w 4 -s Tue Thu
Tue Jan 17
Thu Jan 19
Tue Jan 24
Thu Jan 26
Tue Jan 31
Thu Feb  2
Tue Feb  7
Thu Feb  9

Print Fri, Sat, Sun for three weeks, but also group the output in chunks (-c).

$ ./days.py -s Fri Sat Sun -w 3 -c
Fri Jan 26
Sat Jan 27
Sun Jan 28
----------
Fri Feb  2
Sat Feb  3
Sun Feb  4
----------
Fri Feb  9
Sat Feb 10
Sun Feb 11
----------

Why?

I sometimes teach a class and find it hand to have a list of dates. I also haphazardly put this together over several months without ever thinking about looking at any other tools ¯\_(ツ)_/¯.

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.