Hi,
I'm looking for useful starting points, suggestions, and sample code,
to implement a calendar iterator. Simply, the iterator is seeded with
an initial calendar date, e.g., "03-12-2006", and then subsequent
calls to next return subsequent dates. The seed could be a standard
calendar/datetime object.
iter = calendarIterato r("03-12-2006")
print iter.next()
03-12-2006
A useful extension would be to allow specifiation of iter intervals,
e.g.,
iter = calendarIterato r("03-12-2006 01:00:00", "minutes")
print iter.next()
03-12-2006 01:01:00
Thanks in advance for pointers and suggestions! 4 2208
Oops-- the iter needs to work better than I do! :)
iter = calendarIterato r("03-12-2006")
print iter.next()
03-12-2006
^^^^^^^^^^
03-13-2006
iter = calendarIterato r("03-12-2006 01:00:00", "minutes")
print iter.next()
03-12-2006 01:01:00
^^^^^^^^^^
03-13-2006
MarcusI'm looking for useful starting points, suggestions, and sample
Marcuscode, to implement a calendar iterator.
Have you looked at dateutil? http://labix.org/python-dateutil
>>from dateutil.rrule import rrule, DAILY from dateutil.parser import parse rule = rrule(DAILY, count=5, dtstart=parse(" 2006-03-12")) for d in rule:
... print d
...
2006-03-12 00:00:00
2006-03-13 00:00:00
2006-03-14 00:00:00
2006-03-15 00:00:00
2006-03-16 00:00:00
Skip
On Mar 6, 3:19 pm, s...@pobox.com wrote:
MarcusI'm looking for useful starting points, suggestions, and sample
Marcuscode, to implement a calendar iterator.
Have you looked at dateutil?
http://labix.org/python-dateutil
>>from dateutil.rrule import rrule, DAILY
>>from dateutil.parser import parse
>>rule = rrule(DAILY, count=5, dtstart=parse(" 2006-03-12"))
>>for d in rule:
... print d
...
2006-03-12 00:00:00
2006-03-13 00:00:00
2006-03-14 00:00:00
2006-03-15 00:00:00
2006-03-16 00:00:00
Skip
This is exactly what I was looking for! Thanks so much!!
[Marcus]
I'm looking for useful starting points, suggestions, and sample code,
to implement a calendar iterator. Simply, the iterator is seeded with
an initial calendar date, e.g., "03-12-2006", and then subsequent
calls to next return subsequent dates. The seed could be a standard
calendar/datetime object.
iter = calendarIterato r("03-12-2006")
print iter.next()
03-12-2006
import datetime, time
def calendarIterato r(start, fmt='%m-%d-%Y'):
curr = datetime.date(* time.strptime(s tart, fmt)[:3])
one = datetime.timede lta(1)
while 1:
curr += one
yield curr
if __name__ == '__main__':
iter = calendarIterato r('3-12-2006')
print iter.next()
print iter.next() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cg_news |
last post by:
In short, what I am trying to do is, based on a date, calculate the week of
year (as described in ISO 8601), then calculate the first and last date in
this week period and return them in the format CCYYMMDD. Sounds easy
enough, right??
I am attempting to accomplish this by creating a GregorianCalender which
will get me the week of year. Then by changing the day of week to 1 (start
of week) i'm trying the get the first day of the week,...
|
by: Michele Simionato |
last post by:
Strangely enough, I never needed the datetime and calendar module
before,
so I just looked at them today. I am surprised I don't easily find an
interval
function such this:
import datetime
def interval(day, lastday, step): # not necessarely restricted to days
while day < lastday:
|
by: vinu |
last post by:
I have a javascript file named select.js. This is a file which is use
to pop up a calendar, when clicked on a calendar icon in an ASP file.
have a close button in the calendar. When i click on the button, th
calendar is not closing.
here is the select.js file
x999NS4compatible = (document.layers);
var x999IE4compatible = (document.all);
var x999dayabbs = ;
|
by: Caesar Augustus |
last post by:
First, let me start by saying my asp.net experience is still in it's
infancy so please bare with me as I try to explain my situation.
I have created a single page that with the use of many controls (i.e.
roundedcorners component www.4guysfromrolla.com], buttons and
panels) functions like a tab control. The buttons are
programmatically designed to make the corresponding panel visible.
Sample aspx.vb code:
|
by: thorpk |
last post by:
I posted this problem earlier in the month and some one decided it was
better to change the subject and ask a completely different question.
I am therefore reposting. I am hoping some one can assist with this.
Thanks in advance.
I have an access database that i have added a pop up calendar to, the
Table information for the Date Reported field is
Date/Time
format short date,
input mask is 00/00/0000.
| |
by: mathewgk80 |
last post by:
HI all,
I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page....
I would like to get the code for connecting the javascript to asp.net page...
Please help me...
The javascript code is as follows..
|
by: gubbachchi |
last post by:
Hi all,
Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
|
by: swethak |
last post by:
Hi,
I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the events when click on that date that perticular event displyed in a text box.But my requirement is to when click on that date that related event displyed in same td row not the text box. and also i add the events to that calendar.plz advice how to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |