GithubHelp home page GithubHelp logo

calendary's Introduction

calendary

image

image

Documentation Status

Updates

Python 3

Python calendar and datetime helpers.

Features

Return a list of days for any year

cal = Calendary(2016)

weekdays = cal.weekday_calendar()
today = datetime.datetime.now().date()

for weekday, date in weekdays:
    if date < today:
        print("{0}-{1}-{2} was a {3}".format(date.month, date.day, date.year, weekday))
    elif date == today:
        print("Today is {}".format(weekday))
    else:
        print("{0}-{1}-{2} will be a {3}".format(date.month, date.day, date.year, weekday))

Return a list of only workdays (default: Monday-Friday)

cal = Calendary(2016)

workdays = cal.workday_calendar()

for weekday, date in workdays:
    print(weekday, date)

Change the workweek begin and end

cal = Calendary(2016)

# Work Tuesday - Saturday
workdays = cal.workday_calendar(workweek_start=1, workweek_end=5)

Get the calendar for a specific month

cal = Calendary(2016)

# July calendar
cal.month(7)

# July workweek calendar
cal.month(7, work=True, workweek_start=1, workweek_end=5)

Get a specific date relative to the calendar

cal = Calendary(2016)

# Get the third Thursday in July of 2016
cal.weekday('Thursday', month=7, ordinal=3)

# Get all Thursdays in July 2016
cal.weekday('Thursday', month=7)

# Get the third Thursday in 2016
cal.weekday('Thursday', ordinal=3)

# Get all Thursdays in 2016
cal.weekday('Thursday')

# Get all Mondays and Thursdays in July, 2016 using weekday index values
cal.weekday((0, 3), month=7)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

calendary's People

Contributors

davidhickman avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

bellmj

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.