开发者

Datetime iteration for KML placemarks

All,

I am writing an app that produces 开发者_开发百科64800 polygons and I want each of them to have a unique time stamp. The problem is that my script runs in about 3 seconds which means that there are exactly 3 unique dates spread across all 64k polygons. I've tried going back in time using timedelta() which does actually go back in time from utcnow() but the problem is that it still iterates for 3 seconds with the 3 unique date stamps. I have been working on variations of this...

def time():
    now = datetime.datetime.utcnow()
    start_day = datetime.timedelta(days=-2000)
    timer = now + start_day

Can anyone lend a hand to get me to the 64800 unique time stamps?

Thanks, Adam


You could add a polygon counter to the generated timestamp to differentiate each polygon from the previous one. As a matter of fact, if you do not need accurate wall-clock timestamps - and your messing with the timestamps with timedelta() indicates that you do not - you could even use an abritrary counter as your clock, as long as it's atomically increased.

If you do need accurate timestamps, you could try for sub-second resolution, as mentioned here. Keep in mind, however, that many systems will only provide timestamps in increments of several milli-seconds, which is still plenty of time for more than one polygon to be created, so you will still have to use an additional counter or something similar to create unique timestamps.

We might be able to help you more if you mentioned what these timestamps will be used for...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜