View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030697 | FPC | RTL | public | 2016-10-05 06:40 | 2016-11-27 22:11 |
Reporter | Thaddy de Koning | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | All | OS | OS Version | ||
Product Version | 3.1.1 | Product Build | 34613 | ||
Target Version | 3.2.0 | Fixed in Version | 3.1.1 | ||
Summary | 0030697: Unix time conversion routines one second off | ||||
Description | UnixToDateTime and DateTimeToUnix render a one second difference. | ||||
Steps To Reproduce | uses sysutils,dateutils; var fec: TDateTime; n: LongInt; begin fec := now; n := DateTimeToUnix(fec); writeln(DateTimeToStr(fec), '=', n); fec := UnixToDateTime(n); writeln(DateTimeToStr(fec), '=', n); writeln(''); end. ---- sampleoutput: 5-10-16 06:29:25=1475648966 ..............^v........... 5-10-16 06:29:26=1475648966 | ||||
Additional Information | I don't know which one is wrong. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 34997 | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
related to | 0012894 | closed | Jonas Maebe | DateTimeToUnix rounding error |
|
Since there is rounding/truncating the results should be equal by definition. See valuable discussion here: http://forum.lazarus.freepascal.org/index.php?action=post;topic=34294.0;last_msg=224304 |
|
First of all, it's not always 1 second off: my first test showed: home: ~/fpc/packages/rtl-objpas/src/inc >./testd 27-11-16 14:00:57=1480255257 27-11-16 14:00:57=1480255257 But indeed, it's sometimes 1 second off. I checked the implementation, and instead of round, trunc must be used. Your comment about 'being the same by definition' is somewhat confusing, since the use of round/trunc IMO exactly implies that there can be a difference. Anyway, fixed, thanks for the report. |
|
This change breaks webtbs/tw12894.pp and no new test was added. |
|
Problem was in milliseconds being taken into account. Properly fixed by removing milliseconds. Test added to private testsuite. |
|
No chance for a regression test in fpc/tests :)? |
|
Could you at least create a new, public svn repository with your private tests? That way, should your hard drive crash or so, all of those tests won't simply be gone. At the same time, other people could start adding those tests to the testsuite so they become useful to everyone. |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-10-05 06:40 | Thaddy de Koning | New Issue | |
2016-10-05 09:32 | Thaddy de Koning | Note Added: 0094963 | |
2016-10-05 12:27 | Thaddy de Koning | Note Edited: 0094963 | View Revisions |
2016-11-27 14:10 | Michael Van Canneyt | Fixed in Revision | => 34983 |
2016-11-27 14:10 | Michael Van Canneyt | Note Added: 0096299 | |
2016-11-27 14:10 | Michael Van Canneyt | Status | new => resolved |
2016-11-27 14:10 | Michael Van Canneyt | Fixed in Version | => 3.1.1 |
2016-11-27 14:10 | Michael Van Canneyt | Resolution | open => fixed |
2016-11-27 14:10 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2016-11-27 14:10 | Michael Van Canneyt | Target Version | => 3.2.0 |
2016-11-27 19:01 | Jonas Maebe | Note Added: 0096309 | |
2016-11-27 19:01 | Jonas Maebe | Status | resolved => assigned |
2016-11-27 19:03 | Jonas Maebe | Relationship added | related to 0012894 |
2016-11-27 20:56 | Michael Van Canneyt | Fixed in Revision | 34983 => 34997 |
2016-11-27 20:56 | Michael Van Canneyt | Note Added: 0096311 | |
2016-11-27 20:56 | Michael Van Canneyt | Status | assigned => resolved |
2016-11-27 21:03 | Florian | Note Added: 0096312 | |
2016-11-27 22:11 | Jonas Maebe | Note Added: 0096318 |