Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mktime64() now has an accurate idea of what the system mktime can do.

Let check_max see the time.h configuration before it checks the limits

Split time64_config.h into time64_limits.h so check_max can use time64_config.h

Time::y2038 has to create time64_config.h before it can run check_max
  • Loading branch information...
commit fc700c9686705946bcf6b02d3e4d7f87b064f364 1 parent 6ca9238
@schwern authored
View
2  Makefile
@@ -10,7 +10,7 @@ all : bin/check_max
bin/check_max : $(TIME64_OBJECTS) time64_config.h
-time64.o : time64_config.h time64.h Makefile
+time64.o : time64_config.h time64_limits.h time64.h Makefile
bench : t/bench t/bench_system
time t/bench_system
View
3  bin/check_max.c
@@ -1,5 +1,6 @@
/* A little program to test the limits of your system's time functions */
+#include "time64_config.h"
#include <time.h>
#include <stdio.h>
#include <math.h>
@@ -204,7 +205,7 @@ char * tm_as_json(const struct tm* date) {
);
#ifdef HAS_TM_TM_ZONE
- sprintf(zone_json, ", \"tm_zone\": %s", date->tm_zone);
+ sprintf(zone_json, ", \"tm_zone\": \"%s\"", date->tm_zone);
strcat(date_json, zone_json);
#endif
#ifdef HAS_TM_TM_GMTOFF
View
1  perl/Time-y2038/.gitignore
@@ -1,3 +1,4 @@
check_max
lib/Time/y2038.c
y2038/time64_config.h
+y2038/time64_limits.h
View
6 perl/Time-y2038/Build.PL
@@ -19,10 +19,6 @@ my $build = Local::Module::Build->new(
# extra_compiler_flags => "-g -Wall -ansi -pedantic -Wno-long-long -Wextra -Wdeclaration-after-statement -Wendif-labels -Wconversion",
- PL_files => {
- 'munge_config' => 'y2038/time64_config.h'
- },
-
configure_requires => {
'Module::Build' => '0.2808',
},
@@ -38,8 +34,6 @@ my $build = Local::Module::Build->new(
requires => {
perl => '5.6.1'
},
-
- add_to_cleanup => [qw(check_max.o check_max y2038/time64_config.h)],
);
$build->create_build_script;
View
17 perl/Time-y2038/inc/Local/Module/Build.pm
@@ -8,14 +8,25 @@ use JSON::XS;
sub probe_system_time {
my $self = shift;
- $self->note_time_limits;
$self->note_time_capabilities;
+ $self->munge("y2038/time64_config.h.in" => "y2038/time64_config.h");
+ $self->note_time_limits;
+ $self->munge("y2038/time64_limits.h.in" => "y2038/time64_limits.h");
+}
+
+sub munge {
+ my $self = shift;
+ my($src, $dest) = @_;
+
+ return if $self->up_to_date(["munge_config",$src] => [$dest]);
+ system $^X, "munge_config", $src, $dest;
+ $self->add_to_cleanup($dest);
}
sub note_time_capabilities {
my $self = shift;
- return if $self->up_to_date(["Build", "y2038/time64_config.h.in"], ["y2038/time64_config.h"]);
+ return if $self->up_to_date(["Build", "y2038/time64_limits.h.in"], ["y2038/time64_limits.h"]);
my %tests = (
HAS_TIMEGM => <<'END',
struct tm *date;
@@ -96,7 +107,7 @@ sub note_time_limits {
$exe = $cb->link_executable(objects => $obj, exe_file => $exe);
$exe = $self->find_real_exe($exe);
$self->notes(check_max => $exe);
- $self->add_to_cleanup($exe);
+ $self->add_to_cleanup($obj, $exe);
}
return if $self->up_to_date(["y2038/time64_config.h.in", "munge_config", $exe]
View
3  perl/Time-y2038/munge_config
@@ -7,8 +7,9 @@ my $build = Module::Build->current;
my %config = (%Config, $build->notes);
+my $input_file = shift;
my $output_file = shift;
-my $input_file = $output_file . ".in";
+
open my $input_fh, $input_file or die "Can't open $input_file: $!";
open my $output_fh, ">$output_file" or die "Can't open $output_file: $!";
View
84 perl/Time-y2038/y2038/time64_config.h.in
@@ -88,88 +88,4 @@
#define USE_SYSTEM_MKTIME
/* #define USE_SYSTEM_TIMEGM */
-
-/*
- Maximum and minimum inputs your system's respective time functions
- can correctly handle. time64.h will use your system functions if
- the input falls inside these ranges and corresponding USE_SYSTEM_*
- constant is defined.
-*/
-/* Max/min for localtime() */
-#define SYSTEM_LOCALTIME_MAX %%localtime_max%%
-#define SYSTEM_LOCALTIME_MIN %%localtime_min%%
-
-/* Max/min for gmtime() */
-#define SYSTEM_GMTIME_MAX %%gmtime_max%%
-#define SYSTEM_GMTIME_MIN %%gmtime_min%%
-
-/* Max/min for mktime() */
-#define SYSTEM_MKTIME_MAX_TM_SEC %%mktime_max_tm_sec%%
-#define SYSTEM_MKTIME_MAX_TM_MIN %%mktime_max_tm_min%%
-#define SYSTEM_MKTIME_MAX_TM_HOUR %%mktime_max_tm_hour%%
-#define SYSTEM_MKTIME_MAX_TM_MDAY %%mktime_max_tm_mday%%
-#define SYSTEM_MKTIME_MAX_TM_MON %%mktime_max_tm_mon%%
-#define SYSTEM_MKTIME_MAX_TM_YEAR %%mktime_max_tm_year%%
-#define SYSTEM_MKTIME_MAX_TM_WDAY %%mktime_max_tm_wday%%
-#define SYSTEM_MKTIME_MAX_TM_YDAY %%mktime_max_tm_yday%%
-#define SYSTEM_MKTIME_MAX_TM_ISDST %%mktime_max_tm_isdst%%
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MAX_TM_ZONE %%mktime_max_tm_zone%%
-#endif
-#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MAX_TM_GMTOFF %%mktime_max_tm_gmtoff%%
-#endif
-
-#define SYSTEM_MKTIME_MIN_TM_SEC %%mktime_min_tm_sec%%
-#define SYSTEM_MKTIME_MIN_TM_MIN %%mktime_min_tm_min%%
-#define SYSTEM_MKTIME_MIN_TM_HOUR %%mktime_min_tm_hour%%
-#define SYSTEM_MKTIME_MIN_TM_MDAY %%mktime_min_tm_mday%%
-#define SYSTEM_MKTIME_MIN_TM_MON %%mktime_min_tm_mon%%
-#define SYSTEM_MKTIME_MIN_TM_YEAR %%mktime_min_tm_year%%
-#define SYSTEM_MKTIME_MIN_TM_WDAY %%mktime_min_tm_wday%%
-#define SYSTEM_MKTIME_MIN_TM_YDAY %%mktime_min_tm_yday%%
-#define SYSTEM_MKTIME_MIN_TM_ISDST %%mktime_min_tm_isdst%%
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MIN_TM_ZONE %%mktime_min_tm_zone%%
-#endif
-#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MIN_TM_GMTOFF %%mktime_min_tm_gmtoff%%
-#endif
-
-
-/* Max/min for timegm() */
-#ifdef HAS_TIMEGM
- #define SYSTEM_TIMEGM_MAX_TM_SEC %%timegm_max_tm_sec%%
- #define SYSTEM_TIMEGM_MAX_TM_MIN %%timegm_max_tm_min%%
- #define SYSTEM_TIMEGM_MAX_TM_HOUR %%timegm_max_tm_hour%%
- #define SYSTEM_TIMEGM_MAX_TM_MDAY %%timegm_max_tm_mday%%
- #define SYSTEM_TIMEGM_MAX_TM_MON %%timegm_max_tm_mon%%
- #define SYSTEM_TIMEGM_MAX_TM_YEAR %%timegm_max_tm_year%%
- #define SYSTEM_TIMEGM_MAX_TM_WDAY %%timegm_max_tm_wday%%
- #define SYSTEM_TIMEGM_MAX_TM_YDAY %%timegm_max_tm_yday%%
- #define SYSTEM_TIMEGM_MAX_TM_ISDST %%timegm_max_tm_isdst%%
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MAX_TM_ZONE %%timegm_max_tm_zone%%
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MAX_TM_GMTOFF %%timegm_max_tm_gmtoff%%
- #endif
-
- #define SYSTEM_TIMEGM_MIN_TM_SEC %%timegm_min_tm_sec%%
- #define SYSTEM_TIMEGM_MIN_TM_MIN %%timegm_min_tm_min%%
- #define SYSTEM_TIMEGM_MIN_TM_HOUR %%timegm_min_tm_hour%%
- #define SYSTEM_TIMEGM_MIN_TM_MDAY %%timegm_min_tm_mday%%
- #define SYSTEM_TIMEGM_MIN_TM_MON %%timegm_min_tm_mon%%
- #define SYSTEM_TIMEGM_MIN_TM_YEAR %%timegm_min_tm_year%%
- #define SYSTEM_TIMEGM_MIN_TM_WDAY %%timegm_min_tm_wday%%
- #define SYSTEM_TIMEGM_MIN_TM_YDAY %%timegm_min_tm_yday%%
- #define SYSTEM_TIMEGM_MIN_TM_ISDST %%timegm_min_tm_isdst%%
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MIN_TM_ZONE %%timegm_min_tm_zone%%
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MIN_TM_GMTOFF %%timegm_min_tm_gmtoff%%
- #endif
-#endif
-
#endif /* TIME64_CONFIG_H */
View
88 perl/Time-y2038/y2038/time64_limits.h.in
@@ -0,0 +1,88 @@
+/*
+ Maximum and minimum inputs your system's respective time functions
+ can correctly handle. time64.h will use your system functions if
+ the input falls inside these ranges and corresponding USE_SYSTEM_*
+ constant is defined.
+*/
+
+#ifndef TIME64_LIMITS_H
+#define TIME64_LIMITS_H
+
+/* Max/min for localtime() */
+#define SYSTEM_LOCALTIME_MAX %%localtime_max%%
+#define SYSTEM_LOCALTIME_MIN %%localtime_min%%
+
+/* Max/min for gmtime() */
+#define SYSTEM_GMTIME_MAX %%gmtime_max%%
+#define SYSTEM_GMTIME_MIN %%gmtime_min%%
+
+/* Max/min for mktime() */
+#define SYSTEM_MKTIME_MAX_TM_SEC %%mktime_max_tm_sec%%
+#define SYSTEM_MKTIME_MAX_TM_MIN %%mktime_max_tm_min%%
+#define SYSTEM_MKTIME_MAX_TM_HOUR %%mktime_max_tm_hour%%
+#define SYSTEM_MKTIME_MAX_TM_MDAY %%mktime_max_tm_mday%%
+#define SYSTEM_MKTIME_MAX_TM_MON %%mktime_max_tm_mon%%
+#define SYSTEM_MKTIME_MAX_TM_YEAR %%mktime_max_tm_year%%
+#define SYSTEM_MKTIME_MAX_TM_WDAY %%mktime_max_tm_wday%%
+#define SYSTEM_MKTIME_MAX_TM_YDAY %%mktime_max_tm_yday%%
+#define SYSTEM_MKTIME_MAX_TM_ISDST %%mktime_max_tm_isdst%%
+#ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_MKTIME_MAX_TM_ZONE "%%mktime_max_tm_zone%%"
+#endif
+#ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_MKTIME_MAX_TM_GMTOFF %%mktime_max_tm_gmtoff%%
+#endif
+
+#define SYSTEM_MKTIME_MIN_TM_SEC %%mktime_min_tm_sec%%
+#define SYSTEM_MKTIME_MIN_TM_MIN %%mktime_min_tm_min%%
+#define SYSTEM_MKTIME_MIN_TM_HOUR %%mktime_min_tm_hour%%
+#define SYSTEM_MKTIME_MIN_TM_MDAY %%mktime_min_tm_mday%%
+#define SYSTEM_MKTIME_MIN_TM_MON %%mktime_min_tm_mon%%
+#define SYSTEM_MKTIME_MIN_TM_YEAR %%mktime_min_tm_year%%
+#define SYSTEM_MKTIME_MIN_TM_WDAY %%mktime_min_tm_wday%%
+#define SYSTEM_MKTIME_MIN_TM_YDAY %%mktime_min_tm_yday%%
+#define SYSTEM_MKTIME_MIN_TM_ISDST %%mktime_min_tm_isdst%%
+#ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_MKTIME_MIN_TM_ZONE "%%mktime_min_tm_zone%%"
+#endif
+#ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_MKTIME_MIN_TM_GMTOFF %%mktime_min_tm_gmtoff%%
+#endif
+
+
+/* Max/min for timegm() */
+#ifdef HAS_TIMEGM
+ #define SYSTEM_TIMEGM_MAX_TM_SEC %%timegm_max_tm_sec%%
+ #define SYSTEM_TIMEGM_MAX_TM_MIN %%timegm_max_tm_min%%
+ #define SYSTEM_TIMEGM_MAX_TM_HOUR %%timegm_max_tm_hour%%
+ #define SYSTEM_TIMEGM_MAX_TM_MDAY %%timegm_max_tm_mday%%
+ #define SYSTEM_TIMEGM_MAX_TM_MON %%timegm_max_tm_mon%%
+ #define SYSTEM_TIMEGM_MAX_TM_YEAR %%timegm_max_tm_year%%
+ #define SYSTEM_TIMEGM_MAX_TM_WDAY %%timegm_max_tm_wday%%
+ #define SYSTEM_TIMEGM_MAX_TM_YDAY %%timegm_max_tm_yday%%
+ #define SYSTEM_TIMEGM_MAX_TM_ISDST %%timegm_max_tm_isdst%%
+ #ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_TIMEGM_MAX_TM_ZONE "%%timegm_max_tm_zone%%"
+ #endif
+ #ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_TIMEGM_MAX_TM_GMTOFF %%timegm_max_tm_gmtoff%%
+ #endif
+
+ #define SYSTEM_TIMEGM_MIN_TM_SEC %%timegm_min_tm_sec%%
+ #define SYSTEM_TIMEGM_MIN_TM_MIN %%timegm_min_tm_min%%
+ #define SYSTEM_TIMEGM_MIN_TM_HOUR %%timegm_min_tm_hour%%
+ #define SYSTEM_TIMEGM_MIN_TM_MDAY %%timegm_min_tm_mday%%
+ #define SYSTEM_TIMEGM_MIN_TM_MON %%timegm_min_tm_mon%%
+ #define SYSTEM_TIMEGM_MIN_TM_YEAR %%timegm_min_tm_year%%
+ #define SYSTEM_TIMEGM_MIN_TM_WDAY %%timegm_min_tm_wday%%
+ #define SYSTEM_TIMEGM_MIN_TM_YDAY %%timegm_min_tm_yday%%
+ #define SYSTEM_TIMEGM_MIN_TM_ISDST %%timegm_min_tm_isdst%%
+ #ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_TIMEGM_MIN_TM_ZONE "%%timegm_min_tm_zone%%"
+ #endif
+ #ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_TIMEGM_MIN_TM_GMTOFF %%timegm_min_tm_gmtoff%%
+ #endif
+#endif
+
+#endif /* TIME64_LIMITS_H */
View
148 time64.c
@@ -46,6 +46,97 @@ gmtime64_r() is a 64-bit equivalent of gmtime_r().
#include <time.h>
#include <errno.h>
#include "time64.h"
+#include "time64_limits.h"
+
+struct tm SYSTEM_MKTIME_MAX = {
+SYSTEM_MKTIME_MAX_TM_SEC,
+SYSTEM_MKTIME_MAX_TM_MIN,
+SYSTEM_MKTIME_MAX_TM_HOUR,
+SYSTEM_MKTIME_MAX_TM_MDAY,
+SYSTEM_MKTIME_MAX_TM_MON,
+SYSTEM_MKTIME_MAX_TM_YEAR,
+SYSTEM_MKTIME_MAX_TM_WDAY,
+SYSTEM_MKTIME_MAX_TM_YDAY,
+SYSTEM_MKTIME_MAX_TM_ISDST
+#ifdef HAS_TM_TM_GMTOFF
+,SYSTEM_MKTIME_MAX_TM_GMTOFF
+#else
+,0
+#endif
+#ifdef HAS_TM_TM_ZONE
+,SYSTEM_MKTIME_MAX_TM_ZONE
+#else
+,""
+#endif
+};
+
+const struct tm SYSTEM_MKTIME_MIN = {
+SYSTEM_MKTIME_MIN_TM_SEC,
+SYSTEM_MKTIME_MIN_TM_MIN,
+SYSTEM_MKTIME_MIN_TM_HOUR,
+SYSTEM_MKTIME_MIN_TM_MDAY,
+SYSTEM_MKTIME_MIN_TM_MON,
+SYSTEM_MKTIME_MIN_TM_YEAR,
+SYSTEM_MKTIME_MIN_TM_WDAY,
+SYSTEM_MKTIME_MIN_TM_YDAY,
+SYSTEM_MKTIME_MIN_TM_ISDST
+#ifdef HAS_TM_TM_GMTOFF
+,SYSTEM_MKTIME_MIN_TM_GMTOFF
+#else
+,0
+#endif
+#ifdef HAS_TM_TM_ZONE
+,SYSTEM_MKTIME_MIN_TM_ZONE
+#else
+,""
+#endif
+};
+
+#ifdef HAS_TIMEGM
+const struct tm SYSTEM_TIMEGM_MAX = {
+SYSTEM_TIMEGM_MAX_TM_SEC,
+SYSTEM_TIMEGM_MAX_TM_MIN,
+SYSTEM_TIMEGM_MAX_TM_HOUR,
+SYSTEM_TIMEGM_MAX_TM_MDAY,
+SYSTEM_TIMEGM_MAX_TM_MON,
+SYSTEM_TIMEGM_MAX_TM_YEAR,
+SYSTEM_TIMEGM_MAX_TM_WDAY,
+SYSTEM_TIMEGM_MAX_TM_YDAY,
+SYSTEM_TIMEGM_MAX_TM_ISDST
+#ifdef HAS_TM_TM_GMTOFF
+,SYSTEM_TIMEGM_MAX_TM_GMTOFF
+#else
+,0
+#endif
+#ifdef HAS_TM_TM_ZONE
+,SYSTEM_TIMEGM_MAX_TM_ZONE
+#else
+,""
+#endif
+};
+
+const struct tm SYSTEM_TIMEGM_MIN = {
+SYSTEM_TIMEGM_MIN_TM_SEC,
+SYSTEM_TIMEGM_MIN_TM_MIN,
+SYSTEM_TIMEGM_MIN_TM_HOUR,
+SYSTEM_TIMEGM_MIN_TM_MDAY,
+SYSTEM_TIMEGM_MIN_TM_MON,
+SYSTEM_TIMEGM_MIN_TM_YEAR,
+SYSTEM_TIMEGM_MIN_TM_WDAY,
+SYSTEM_TIMEGM_MIN_TM_YDAY,
+SYSTEM_TIMEGM_MIN_TM_ISDST
+#ifdef HAS_TM_TM_GMTOFF
+,SYSTEM_TIMEGM_MIN_TM_GMTOFF
+#else
+,0
+#endif
+#ifdef HAS_TM_TM_ZONE
+,SYSTEM_TIMEGM_MIN_TM_ZONE
+#else
+,""
+#endif
+};
+#endif HAS_TIMEGM
/* Spec says except for stftime() and the _r() functions, these
@@ -171,6 +262,59 @@ static int is_exception_century(Year year)
}
+/* Compare two dates.
+ The result is like cmp.
+ Ignores things like gmtoffset and dst
+*/
+int cmp_date( const struct TM* left, const struct tm* right ) {
+ if( left->tm_year > right->tm_year )
+ return 1;
+ else if( left->tm_year < right->tm_year )
+ return -1;
+
+ if( left->tm_mon > right->tm_mon )
+ return 1;
+ else if( left->tm_mon < right->tm_mon )
+ return -1;
+
+ if( left->tm_mday > right->tm_mday )
+ return 1;
+ else if( left->tm_mday < right->tm_mday )
+ return -1;
+
+ if( left->tm_hour > right->tm_hour )
+ return 1;
+ else if( left->tm_hour < right->tm_hour )
+ return -1;
+
+ if( left->tm_min > right->tm_min )
+ return 1;
+ else if( left->tm_min < right->tm_min )
+ return -1;
+
+ if( left->tm_sec > right->tm_sec )
+ return 1;
+ else if( left->tm_sec < right->tm_sec )
+ return -1;
+
+ return 0;
+}
+
+
+/* Check if a date is safely inside a range.
+ The intention is to check if its a few days inside.
+*/
+int date_in_safe_range( const struct TM* date, const struct tm* min, const struct tm* max ) {
+ if( cmp_date(date, min) == -1 )
+ return 0;
+
+ if( cmp_date(date, max) == 1 )
+ return 0;
+
+ return 1;
+}
+
+
/* timegm() is not in the C or POSIX spec, but it is such a useful
extension I would be remiss in leaving it out. Also I need it
for localtime64()
@@ -467,7 +611,9 @@ Time64_T mktime64(const struct TM *input_date) {
Time64_T time;
Year year = input_date->tm_year + 1900;
- if( MIN_SAFE_YEAR <= year && year <= MAX_SAFE_YEAR ) {
+ if( date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) )
+ {
+ printf("Using system mktime\n");
copy_TM64_to_tm(input_date, &safe_date);
return (Time64_T)mktime(&safe_date);
}
View
5 time64.h
@@ -1,9 +1,8 @@
-#include <time.h>
-#include "time64_config.h"
-
#ifndef TIME64_H
# define TIME64_H
+#include <time.h>
+#include "time64_config.h"
/* Set our custom types */
typedef INT_64_T Int64;
View
83 time64_config.h
@@ -79,87 +79,4 @@
#define USE_SYSTEM_MKTIME
/* #define USE_SYSTEM_TIMEGM */
-
-/*
- Maximum and minimum inputs your system's respective time functions
- can correctly handle. time64.h will use your system functions if
- the input falls inside these ranges and corresponding USE_SYSTEM_*
- constant is defined.
-*/
-/* Max/min for localtime() */
-#define SYSTEM_LOCALTIME_MAX 2147483647
-#define SYSTEM_LOCALTIME_MIN -2147483647-1
-
-/* Max/min for gmtime() */
-#define SYSTEM_GMTIME_MAX 2147483647
-#define SYSTEM_GMTIME_MIN -2147483647-1
-
-/* Max/min for mktime() */
-#define SYSTEM_MKTIME_MAX_TM_SEC 7
-#define SYSTEM_MKTIME_MAX_TM_MIN 14
-#define SYSTEM_MKTIME_MAX_TM_HOUR 19
-#define SYSTEM_MKTIME_MAX_TM_MDAY 18
-#define SYSTEM_MKTIME_MAX_TM_MON 0
-#define SYSTEM_MKTIME_MAX_TM_YEAR 138
-#define SYSTEM_MKTIME_MAX_TM_WDAY 1
-#define SYSTEM_MKTIME_MAX_TM_YDAY 17
-#define SYSTEM_MKTIME_MAX_TM_ISDST 0
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MAX_TM_ZONE "PST"
-#endif
-#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MAX_TM_GMTOFF -28800
-#endif
-
-#define SYSTEM_MKTIME_MIN_TM_SEC 52
-#define SYSTEM_MKTIME_MIN_TM_MIN 45
-#define SYSTEM_MKTIME_MIN_TM_HOUR 12
-#define SYSTEM_MKTIME_MIN_TM_MDAY 13
-#define SYSTEM_MKTIME_MIN_TM_MON 11
-#define SYSTEM_MKTIME_MIN_TM_YEAR 1
-#define SYSTEM_MKTIME_MIN_TM_WDAY 5
-#define SYSTEM_MKTIME_MIN_TM_YDAY 346
-#define SYSTEM_MKTIME_MIN_TM_ISDST 0
-#ifdef HAS_TM_TM_ZONE
- #define SYSTEM_MKTIME_MIN_TM_ZONE "PST"
-#endif
-#ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_MKTIME_MIN_TM_GMTOFF -28800
-#endif
-
-/* Max/min for timegm() */
-#ifdef HAS_TIMEGM
- #define SYSTEM_TIMEGM_MAX_TM_SEC 7
- #define SYSTEM_TIMEGM_MAX_TM_MIN 14
- #define SYSTEM_TIMEGM_MAX_TM_HOUR 3
- #define SYSTEM_TIMEGM_MAX_TM_MDAY 19
- #define SYSTEM_TIMEGM_MAX_TM_MON 0
- #define SYSTEM_TIMEGM_MAX_TM_YEAR 138
- #define SYSTEM_TIMEGM_MAX_TM_WDAY 2
- #define SYSTEM_TIMEGM_MAX_TM_YDAY 18
- #define SYSTEM_TIMEGM_MAX_TM_ISDST 0
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MAX_TM_ZONE "UTC"
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MAX_TM_GMTOFF 0
- #endif
-
- #define SYSTEM_TIMEGM_MIN_TM_SEC 52
- #define SYSTEM_TIMEGM_MIN_TM_MIN 45
- #define SYSTEM_TIMEGM_MIN_TM_HOUR 20
- #define SYSTEM_TIMEGM_MIN_TM_MDAY 13
- #define SYSTEM_TIMEGM_MIN_TM_MON 11
- #define SYSTEM_TIMEGM_MIN_TM_YEAR 1
- #define SYSTEM_TIMEGM_MIN_TM_WDAY 5
- #define SYSTEM_TIMEGM_MIN_TM_YDAY 346
- #define SYSTEM_TIMEGM_MIN_TM_ISDST 0
- #ifdef HAS_TM_TM_ZONE
- #define SYSTEM_TIMEGM_MIN_TM_ZONE "UTC"
- #endif
- #ifdef HAS_TM_TM_GMTOFF
- #define SYSTEM_TIMEGM_MIN_TM_GMTOFF 0
- #endif
-#endif
-
#endif /* TIME64_CONFIG_H */
View
87 time64_limits.h
@@ -0,0 +1,87 @@
+/*
+ Maximum and minimum inputs your system's respective time functions
+ can correctly handle. time64.h will use your system functions if
+ the input falls inside these ranges and corresponding USE_SYSTEM_*
+ constant is defined.
+*/
+
+#ifndef TIME64_LIMITS_H
+#define TIME64_LIMITS_H
+
+/* Max/min for localtime() */
+#define SYSTEM_LOCALTIME_MAX 2147483647
+#define SYSTEM_LOCALTIME_MIN -2147483647-1
+
+/* Max/min for gmtime() */
+#define SYSTEM_GMTIME_MAX 2147483647
+#define SYSTEM_GMTIME_MIN -2147483647-1
+
+/* Max/min for mktime() */
+#define SYSTEM_MKTIME_MAX_TM_SEC 7
+#define SYSTEM_MKTIME_MAX_TM_MIN 14
+#define SYSTEM_MKTIME_MAX_TM_HOUR 19
+#define SYSTEM_MKTIME_MAX_TM_MDAY 18
+#define SYSTEM_MKTIME_MAX_TM_MON 0
+#define SYSTEM_MKTIME_MAX_TM_YEAR 138
+#define SYSTEM_MKTIME_MAX_TM_WDAY 1
+#define SYSTEM_MKTIME_MAX_TM_YDAY 17
+#define SYSTEM_MKTIME_MAX_TM_ISDST 0
+#ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_MKTIME_MAX_TM_ZONE "PST"
+#endif
+#ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_MKTIME_MAX_TM_GMTOFF -28800
+#endif
+
+#define SYSTEM_MKTIME_MIN_TM_SEC 52
+#define SYSTEM_MKTIME_MIN_TM_MIN 45
+#define SYSTEM_MKTIME_MIN_TM_HOUR 12
+#define SYSTEM_MKTIME_MIN_TM_MDAY 13
+#define SYSTEM_MKTIME_MIN_TM_MON 11
+#define SYSTEM_MKTIME_MIN_TM_YEAR 1
+#define SYSTEM_MKTIME_MIN_TM_WDAY 5
+#define SYSTEM_MKTIME_MIN_TM_YDAY 346
+#define SYSTEM_MKTIME_MIN_TM_ISDST 0
+#ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_MKTIME_MIN_TM_ZONE "PST"
+#endif
+#ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_MKTIME_MIN_TM_GMTOFF -28800
+#endif
+
+/* Max/min for timegm() */
+#ifdef HAS_TIMEGM
+ #define SYSTEM_TIMEGM_MAX_TM_SEC 7
+ #define SYSTEM_TIMEGM_MAX_TM_MIN 14
+ #define SYSTEM_TIMEGM_MAX_TM_HOUR 3
+ #define SYSTEM_TIMEGM_MAX_TM_MDAY 19
+ #define SYSTEM_TIMEGM_MAX_TM_MON 0
+ #define SYSTEM_TIMEGM_MAX_TM_YEAR 138
+ #define SYSTEM_TIMEGM_MAX_TM_WDAY 2
+ #define SYSTEM_TIMEGM_MAX_TM_YDAY 18
+ #define SYSTEM_TIMEGM_MAX_TM_ISDST 0
+ #ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_TIMEGM_MAX_TM_ZONE "UTC"
+ #endif
+ #ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_TIMEGM_MAX_TM_GMTOFF 0
+ #endif
+
+ #define SYSTEM_TIMEGM_MIN_TM_SEC 52
+ #define SYSTEM_TIMEGM_MIN_TM_MIN 45
+ #define SYSTEM_TIMEGM_MIN_TM_HOUR 20
+ #define SYSTEM_TIMEGM_MIN_TM_MDAY 13
+ #define SYSTEM_TIMEGM_MIN_TM_MON 11
+ #define SYSTEM_TIMEGM_MIN_TM_YEAR 1
+ #define SYSTEM_TIMEGM_MIN_TM_WDAY 5
+ #define SYSTEM_TIMEGM_MIN_TM_YDAY 346
+ #define SYSTEM_TIMEGM_MIN_TM_ISDST 0
+ #ifdef HAS_TM_TM_ZONE
+ #define SYSTEM_TIMEGM_MIN_TM_ZONE "UTC"
+ #endif
+ #ifdef HAS_TM_TM_GMTOFF
+ #define SYSTEM_TIMEGM_MIN_TM_GMTOFF 0
+ #endif
+#endif
+
+#endif /* TIME64_LIMITS_H */
Please sign in to comment.
Something went wrong with that request. Please try again.