A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/308266.html below:

Find day of week from month and year

Find day of week from month and year Find day of week from month and yeartryit joseph.steffl at medtronic.com
Wed Sep 14 13:10:56 EDT 2005
Laguna wrote:
> Hi Gurus,
>
> I want to find the expiration date of stock options (3rd Friday of the
> month) for an any give month and year. I have tried a few tricks with
> the functions provided by the built-in module time, but the problem was
> that the 9 element tuple need to be populated correctly. Can anyone
> help me out on this one?
>
> Thanks a bunch,
> Laguna
>
> Requirements:
>
> d0 = expiration(9, 2005) # d0 would be 16
> d1 = expiration(6, 2003) # d1 would be 20
> d2 = expiration(2, 2006) # d2 would be 17

>>> import calendar
>>> [y[4] for y in calendar.monthcalendar(2005, 9) if y[4]!=0][2]
16
>>> [y[4] for y in calendar.monthcalendar(2003, 6) if y[4]!=0][2]
20
>>> [y[4] for y in calendar.monthcalendar(2006, 2) if y[4]!=0][2]
17


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4