Bug 1344014
Summary: | mktime behavior changed | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Steve Grubb <sgrubb> |
Component: | glibc | Assignee: | Carlos O'Donell <codonell> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 23 | CC: | arjun.is, codonell, dj, fweimer, jakub, law, mfabian, pfrankli, siddhesh |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-06-08 15:31:38 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Steve Grubb
2016-06-08 13:59:05 UTC
(In reply to Steve Grubb from comment #0) > void init_time(const char *da, const char *ti) > { > struct tm d; > strptime(da, "%x", &d); > strptime(ti, "%X", &d); > start_time = mktime(&d); > } Please test with an initializer: struct tm d = {}; I suspect you see essentially random differences due to uninitialized data. Thanks. That seems to make them both consistent. But it leads to the actual problem of now the time is just wrong. If a user types 17:00:00 in as the time, why does mktime change it to 18:00:00? How to you get reliable time conversion in both December and June? (I understand this is not a bz topic and will close this as not a bug.) This seems to be the recipe to get reliable time conversion: struct tm d; clear_tm(&d); strptime(da, "%x", &d); start_time = mktime(&d); strptime(ti, "%X", &d); start_time = mktime(&d); strptime is not setting the dst flag on the date conversion so you have to let mktime fix it, then you can do the time conversion and have correct time converted into time_t. |