Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use timelocal instead of mktime in timelocal64 in OpenBSD #1906

Closed
wants to merge 1 commit into from

2 participants

@tonysidaway

OpenBSD is pernickerty about struct_tm in mktime. Setting tm_isdst to -1 prior to calling mktime (which is what timelocal does) makes mktime less pedantic.

@dbussink
Owner

Isn't a better fix then to explicitly set tm_isdst to -1 before we call the timelocal64 function in other places? That should work across all platforms then and that way we don't have to conditionalize code based on the platform.

@tonysidaway

I'll go with whatever other developers want. I only know that using mktime here is a bug in OpenBSD. The cause of the test spec failure appears to be a use of the PST timezone with is_dst set to 0 and a date in December. Since timelocal is listed as deprecated in any case, perhaps explicitly setting tm.is_dst to -1 is the best way to go.

http://www.openbsd.org/cgi-bin/man.cgi?query=timelocal&sektion=3

@dbussink dbussink closed this pull request from a commit
@dbussink dbussink Explicitly set tm_isdst before using timelocal64
When using timelocal64, we always want it to compute the DST and not use
what we provide. This happens on all platforms except OpenBSD by
default.

Fixes #1906
0f7d453
@dbussink dbussink closed this in 0f7d453
@roshats roshats referenced this pull request from a commit in roshats/rubinius
@dbussink dbussink Explicitly set tm_isdst before using timelocal64
When using timelocal64, we always want it to compute the DST and not use
what we provide. This happens on all platforms except OpenBSD by
default.

Fixes #1906
3ee6973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 vm/util/time64.c
View
4 vm/util/time64.c
@@ -338,7 +338,11 @@ time64_t mktime64(struct tm64* tm64) {
}
time64_t timelocal64(struct tm64* tm64) {
+#ifdef __OpenBSD__
+ return timestamp64(timelocal, tm64);
+#else
return timestamp64(mktime, tm64);
+#endif
}
time64_t timegm64(struct tm64* tm64) {
Something went wrong with that request. Please try again.