Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.3.20] croniter return repeated timestamps in a particular hour (might relate to daylight saving time but not sure) #96

Closed
royitaqi opened this issue Jan 23, 2018 · 4 comments

Comments

@royitaqi
Copy link

royitaqi commented Jan 23, 2018

System:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

Versions:

$ python --version
Python 3.5.2
$ pip list | grep croniter
croniter (0.3.20)

Test code (name it test.py):

from croniter import croniter
from datetime import datetime
import pandas as pd
import tzlocal
import pytz
import sys

local = pytz.timezone('America/Los_Angeles')
print(local)

c = croniter('* * * * *', datetime(2017, 3, 12, tzinfo=local))
s = set()
l = list()
while True:
    t = c.get_next(datetime)
    ms = int(t.timestamp() * 1000)
    if ms >= 1489309140000:
        s.add(ms)
        l.append(ms)
        print(t, ms)
    if ms >= 1489312800000:
        break

print(len(s))
print(len(l))
assert(len(s) == len(l))

Expected behavior:

  • Console output should not contain repeated timestamps.
  • Console output should not contain timestamps which go backwards in time.
  • Assertion in the code should pass, since timestamps should not repeat.

Observed behavior:

  • Console output contains repeated timestamps.
  • Console output contains timestamps which go backwards in time.
  • Assertion in the code fails.

Observed console output:

$ python test.py
America/Los_Angeles
2017-03-12 00:59:00-08:00 1489309140000
2017-03-12 01:00:00-08:00 1489309200000
2017-03-12 01:01:00-08:00 1489309260000
2017-03-12 01:02:00-08:00 1489309320000
2017-03-12 01:03:00-08:00 1489309380000
2017-03-12 01:04:00-08:00 1489309440000
2017-03-12 01:05:00-08:00 1489309500000
2017-03-12 01:06:00-08:00 1489309560000
2017-03-12 01:07:00-08:00 1489309620000
2017-03-12 01:08:00-08:00 1489309680000
2017-03-12 01:09:00-08:00 1489309740000
2017-03-12 01:10:00-08:00 1489309800000
2017-03-12 01:11:00-08:00 1489309860000
2017-03-12 01:12:00-08:00 1489309920000
2017-03-12 01:13:00-08:00 1489309980000
2017-03-12 01:14:00-08:00 1489310040000
2017-03-12 01:15:00-08:00 1489310100000
2017-03-12 01:16:00-08:00 1489310160000
2017-03-12 01:17:00-08:00 1489310220000
2017-03-12 01:18:00-08:00 1489310280000
2017-03-12 01:19:00-08:00 1489310340000
2017-03-12 01:20:00-08:00 1489310400000
2017-03-12 01:21:00-08:00 1489310460000
2017-03-12 01:22:00-08:00 1489310520000
2017-03-12 01:23:00-08:00 1489310580000
2017-03-12 01:24:00-08:00 1489310640000
2017-03-12 01:25:00-08:00 1489310700000
2017-03-12 01:26:00-08:00 1489310760000
2017-03-12 01:27:00-08:00 1489310820000
2017-03-12 01:28:00-08:00 1489310880000
2017-03-12 01:29:00-08:00 1489310940000
2017-03-12 01:30:00-08:00 1489311000000
2017-03-12 01:31:00-08:00 1489311060000
2017-03-12 01:32:00-08:00 1489311120000
2017-03-12 01:33:00-08:00 1489311180000
2017-03-12 01:34:00-08:00 1489311240000
2017-03-12 01:35:00-08:00 1489311300000
2017-03-12 01:36:00-08:00 1489311360000
2017-03-12 01:37:00-08:00 1489311420000
2017-03-12 01:38:00-08:00 1489311480000
2017-03-12 01:39:00-08:00 1489311540000
2017-03-12 01:40:00-08:00 1489311600000
2017-03-12 01:41:00-08:00 1489311660000
2017-03-12 01:42:00-08:00 1489311720000
2017-03-12 01:43:00-08:00 1489311780000
2017-03-12 01:44:00-08:00 1489311840000
2017-03-12 01:45:00-08:00 1489311900000
2017-03-12 01:46:00-08:00 1489311960000
2017-03-12 01:47:00-08:00 1489312020000
2017-03-12 01:48:00-08:00 1489312080000
2017-03-12 01:49:00-08:00 1489312140000
2017-03-12 01:50:00-08:00 1489312200000
2017-03-12 01:51:00-08:00 1489312260000
2017-03-12 01:52:00-08:00 1489312320000
2017-03-12 01:53:00-08:00 1489312380000
2017-03-12 01:54:00-08:00 1489312440000
2017-03-12 01:55:00-08:00 1489312500000
2017-03-12 01:56:00-08:00 1489312560000
2017-03-12 01:57:00-08:00 1489312620000
2017-03-12 01:58:00-08:00 1489312680000
2017-03-12 01:59:00-08:00 1489312740000
2017-03-12 02:00:00-07:00 1489309200000
2017-03-12 01:01:00-08:00 1489309260000
2017-03-12 01:02:00-08:00 1489309320000
2017-03-12 01:03:00-08:00 1489309380000
2017-03-12 01:04:00-08:00 1489309440000
2017-03-12 01:05:00-08:00 1489309500000
2017-03-12 01:06:00-08:00 1489309560000
2017-03-12 01:07:00-08:00 1489309620000
2017-03-12 01:08:00-08:00 1489309680000
2017-03-12 01:09:00-08:00 1489309740000
2017-03-12 01:10:00-08:00 1489309800000
2017-03-12 01:11:00-08:00 1489309860000
2017-03-12 01:12:00-08:00 1489309920000
2017-03-12 01:13:00-08:00 1489309980000
2017-03-12 01:14:00-08:00 1489310040000
2017-03-12 01:15:00-08:00 1489310100000
2017-03-12 01:16:00-08:00 1489310160000
2017-03-12 01:17:00-08:00 1489310220000
2017-03-12 01:18:00-08:00 1489310280000
2017-03-12 01:19:00-08:00 1489310340000
2017-03-12 01:20:00-08:00 1489310400000
2017-03-12 01:21:00-08:00 1489310460000
2017-03-12 01:22:00-08:00 1489310520000
2017-03-12 01:23:00-08:00 1489310580000
2017-03-12 01:24:00-08:00 1489310640000
2017-03-12 01:25:00-08:00 1489310700000
2017-03-12 01:26:00-08:00 1489310760000
2017-03-12 01:27:00-08:00 1489310820000
2017-03-12 01:28:00-08:00 1489310880000
2017-03-12 01:29:00-08:00 1489310940000
2017-03-12 01:30:00-08:00 1489311000000
2017-03-12 01:31:00-08:00 1489311060000
2017-03-12 01:32:00-08:00 1489311120000
2017-03-12 01:33:00-08:00 1489311180000
2017-03-12 01:34:00-08:00 1489311240000
2017-03-12 01:35:00-08:00 1489311300000
2017-03-12 01:36:00-08:00 1489311360000
2017-03-12 01:37:00-08:00 1489311420000
2017-03-12 01:38:00-08:00 1489311480000
2017-03-12 01:39:00-08:00 1489311540000
2017-03-12 01:40:00-08:00 1489311600000
2017-03-12 01:41:00-08:00 1489311660000
2017-03-12 01:42:00-08:00 1489311720000
2017-03-12 01:43:00-08:00 1489311780000
2017-03-12 01:44:00-08:00 1489311840000
2017-03-12 01:45:00-08:00 1489311900000
2017-03-12 01:46:00-08:00 1489311960000
2017-03-12 01:47:00-08:00 1489312020000
2017-03-12 01:48:00-08:00 1489312080000
2017-03-12 01:49:00-08:00 1489312140000
2017-03-12 01:50:00-08:00 1489312200000
2017-03-12 01:51:00-08:00 1489312260000
2017-03-12 01:52:00-08:00 1489312320000
2017-03-12 01:53:00-08:00 1489312380000
2017-03-12 01:54:00-08:00 1489312440000
2017-03-12 01:55:00-08:00 1489312500000
2017-03-12 01:56:00-08:00 1489312560000
2017-03-12 01:57:00-08:00 1489312620000
2017-03-12 01:58:00-08:00 1489312680000
2017-03-12 01:59:00-08:00 1489312740000
2017-03-12 03:00:00-07:00 1489312800000
62
122
Traceback (most recent call last):
  File "test.py", line 26, in <module>
    assert(len(s) == len(l))
AssertionError

Notice that every minute between 2017-03-12 01:00:00-08:00 and 2017-03-12 01:59:00-08:00 are repeated once, apparently at the hour of daylight saving time switch-over.

@royitaqi
Copy link
Author

Same problem happens if the asked output type is float (e.g. c.get_next(float)).

@royitaqi royitaqi changed the title croniter return repeated timestamps in a particular hour (might relate to daylight saving time but not sure) [0.3.20] croniter return repeated timestamps in a particular hour (might relate to daylight saving time but not sure) Jan 23, 2018
@kiorky
Copy link
Collaborator

kiorky commented Jan 24, 2018

Just fyi, You are listened, just in an heavy charge for now.

@kiorky
Copy link
Collaborator

kiorky commented Jan 24, 2018

PR are welcome ;)

@kiorky
Copy link
Collaborator

kiorky commented Apr 10, 2020

dup #90

@kiorky kiorky closed this as completed Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants