calendar

Calendar Module in Python not working

Calendar Module in Python not working Question: I tried to use the python calendar module in version 3.5.2 with: import calendar yy = 2016 mm = 12 # To ask month and year from the user # yy = int(input(“Enter year: “)) # mm = int(input(“Enter month: “)) display=calendar.calendar(yy,mm) # display the calendar print(display) but …

Total answers: 2

Django attaching events to days in a calendar?

Django attaching events to days in a calendar? Question: I have built a basic calendar which generates a table with the current month (taken from the URL) using the built-in calendar.Calendar function, but I would like to attach events to the days that are generated. What would be the best way to do that? Currently …

Total answers: 2

Create trading holiday calendar with Pandas

Create trading holiday calendar with Pandas Question: I’m trying to create a Trading calendar using Pandas. I’m able to create a cal instance based on the USFederalHolidayCalendar. The USFederalHolidayCalendar is not consistent with the Trading calendar in that the Trading calendar doesn’t include Columbus Day and Veteran’s Day. However, the Trading calendar includes Good Friday …

Total answers: 4

How to check what month it is? Python

How to check what month it is? Python Question: I am writing a code which assigns certain data to different seasons. I wanted the program to print the various data depending on what month it currently is. Autumn = ‘September’ Autumn = ‘October’ Autumn = ‘November’ Autumn = ‘December’ Autumn = ‘January’ #(The start Jan …

Total answers: 4

Count Dates in Python

Count Dates in Python Question: I am trying to count the number of Friday the 13ths per year from 1950-2050 using Python (I know, a little late). I am not familiar with any date/calendar packages to use. Any thoughts? Asked By: mike || Source Answers: Is it some kind of exercise or homework? I faintly …

Total answers: 6

Converting to and from Hindu calendar

Converting to and from Hindu calendar Question: How can I convert unix time to Hindu calendar­Wikipedia time and the other way round in php, Perl or Python or Java? I know I can convert to Hebrew and Jewish. But Hindu is not an option. To be more specific, I’m talking about the Hindu lunar calendar. …

Total answers: 5

Python: Converting from `datetime.datetime` to `time.time`

Python: Converting from `datetime.datetime` to `time.time` Question: In Python, how do I convert a datetime.datetime into the kind of float that I would get from the time.time function? Asked By: Ram Rachum || Source Answers: Given a datetime.datetime object dt, you could use (dt – datetime.datetime.utcfromtimestamp(0)).total_seconds() Example: >>> dt = datetime.datetime.now(); t = time.time() >>> …

Total answers: 5

Return a list of weekdays, starting with given weekday

Return a list of weekdays, starting with given weekday Question: My task is to define a function weekdays(weekday) that returns a list of weekdays, starting with the given weekday. It should work like this: >>> weekdays(‘Wednesday’) [‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’, ‘Monday’, ‘Tuesday’] So far I’ve come up with this one: def weekdays(weekday): days = …

Total answers: 12

Moon / Lunar Phase Algorithm

Moon / Lunar Phase Algorithm Question: Does anyone know an algorithm to either calculate the moon phase or age on a given date or find the dates for new/full moons in a given year? Googling tells me the answer is in some Astronomy book, but I don’t really want to buy a whole book when …

Total answers: 8

How can I select all of the Sundays for a year using Python?

How can I select all of the Sundays for a year using Python? Question: Using Python… How can I select all of the Sundays (or any day for that matter) in a year? [ ’01/03/2010′,’01/10/2010′,’01/17/2010′,’01/24/2010′, …] These dates represent the Sundays for 2010. This could also apply to any day of the week I suppose. …

Total answers: 10