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

Formatting dates sometimes returns January zeroth #134

Closed
creideiki opened this issue Jan 16, 2019 · 4 comments
Closed

Formatting dates sometimes returns January zeroth #134

creideiki opened this issue Jan 16, 2019 · 4 comments
Assignees
Labels

Comments

@creideiki
Copy link

I had some weird errors processing CSV output from psort, and tracked them down to a couple of lines having date stamps of "01/00/1971" or "01/00/1974", which seems wrong. Outputting JSON from psort instead, I got the timestamps in POSIX format, and tracked the error to dfdatetime.

The original error occurred on an up-to-date Fedora 29, running plaso-20181219-3 out of LiFTeR on Python 2.7.15, but the error is still there when running the current master of dfdatetime (0b23e03).

$ python2
>>> from dfdatetime import posix_time as dfdatetime_posix_time
>>> dfdatetime_posix_time.PosixTime(31511228).CopyToDateTimeString()
u'1971-01-00 17:07:08'
>>> dfdatetime_posix_time.PosixTime(126189827).CopyToDateTimeString()
u'1974-01-00 12:43:47'

The same bug is present in the PosixTimeInMilliseconds() and PosixTimeInMicroseconds() interfaces (which is what psort actually uses).

date says those timestamps were on the 31:st of December the year before, not the zeroth of January:

$ env LC_TIME=en_US TZ=UTC date --date='@31511228'
Thu Dec 31 17:07:08 UTC 1970
$ env LC_TIME=en_US TZ=UTC date --date='@126189827'
Mon Dec 31 12:43:47 UTC 1973
@joachimmetz joachimmetz self-assigned this Jan 16, 2019
@joachimmetz
Copy link
Member

Thx for the report I'll have a look as soon time permits

@joachimmetz
Copy link
Member

Issue is that interface._GetDateValues does not correctly handle number of days (in year) of 0.

Pending fixes: #135

With fix:

In [2]: from dfdatetime import posix_time

In [3]: posix_time.PosixTime(31511228).CopyToDateTimeString()
Out[3]: u'1970-12-31 17:07:08'

In [4]: posix_time.PosixTime(126189827).CopyToDateTimeString()
Out[4]: u'1973-12-31 12:43:47'

@joachimmetz
Copy link
Member

Changes merged and new pre-release made available.

@creideiki
Copy link
Author

Thanks! I just tried the 20190116 release on my real data, and it solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants