Printing list of dates starting today

L

Luka Djigas

Hello everyone,

please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
02.09.2008. tue
03.09.2008. wed
et cetera

Is there some intristic function in python which can help me with this
or do I have to do the calendar calculation by hand ?

Would appreciate all the help I can get.

Regards
Luka Djigas
 
F

Fredrik Lundh

Luka said:
please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
>
02.09.2008. tue
03.09.2008. wed
et cetera

Is there some intristic function in python which can help me with this
or do I have to do the calendar calculation by hand ?
.... print d.strftime("%d.%m.%Y. %a").lower()
.... d += datetime.timedelta(days=1)
....
01.09.2008. mon
02.09.2008. tue
03.09.2008. wed
04.09.2008. thu
05.09.2008. fri
06.09.2008. sat
07.09.2008. sun
08.09.2008. mon
09.09.2008. tue
10.09.2008. wed

</F>
 
A

Ari Makela

please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...

There are several ways to do it. Have a look at the documentation
of modules time and datetime. For this exact problem time is the
most straighforward one.
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
02.09.2008. tue
03.09.2008. wed

0 hauva@laphroaig:~
$ /usr/bin/python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information..... t = time.gmtime(time.time() + i * DAY)
.... print time.strftime('%d.%m.%Y, %a', t)
....
01.09.2008, Mon
02.09.2008, Tue
03.09.2008, Wed
04.09.2008, Thu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top