This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Time t 1970 check #203
Merged
Merged
Time t 1970 check #203
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c1144f7
Added compile try_run() test to check mktime() for dates before 1970;…
joakim-hove 2f6de7b
Added function ecl_util_make_date() which check symbol TIME_T_1970 - …
joakim-hove f9c47ff
Replacing util_make_date() -> ecl_util_make_date() in all of libecl
joakim-hove cf2a8b9
Changed to #define symbol TIME_T_64BIT_ACCEPT_PRE1970 + explicitly ch…
joakim-hove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <dirent.h> | ||
|
||
int main(int argc, char ** argv) { | ||
struct tm ts; | ||
ts.tm_sec = 0; | ||
ts.tm_min = 0; | ||
ts.tm_hour = 0; | ||
ts.tm_mday = 1; | ||
ts.tm_mon = 0; | ||
ts.tm_year = 0; | ||
ts.tm_isdst = -1; | ||
{ | ||
time_t t = mktime( &ts ); | ||
if (t == -1) | ||
exit(0); | ||
else | ||
exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright (C) 2013 Statoil ASA, Norway. | ||
|
||
The file 'ecl_util_make_date_no_shift.c' is part of ERT - Ensemble based Reservoir Tool. | ||
|
||
ERT is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY | ||
WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> | ||
for more details. | ||
*/ | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#include <ert/util/test_util.h> | ||
#include <ert/util/time_t_vector.h> | ||
#include <ert/util/util.h> | ||
|
||
#include <ert/ecl/ecl_util.h> | ||
|
||
|
||
void test_date(int mday, int month , int year) { | ||
time_t t0 = ecl_util_make_date( mday , month , year ); | ||
time_t t1 = util_make_date( mday , month , year); | ||
|
||
test_assert_time_t_equal( t0 , t1 ); | ||
} | ||
|
||
void test_offset(int mday, int month , int year) { | ||
int year_offset; | ||
ecl_util_make_date__( mday , month , year , &year_offset); | ||
test_assert_int_equal( 0 , year_offset ); | ||
} | ||
|
||
|
||
|
||
int main(int argc , char ** argv) { | ||
test_date(10,10,2000); | ||
test_offset(10,10,2000); | ||
// test_assert_util_abort( make_date( 1 , 1 , 0); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* Copyright (C) 2013 Statoil ASA, Norway. | ||
|
||
The file 'ecl_util_make_date_shift.c' is part of ERT - Ensemble based Reservoir Tool. | ||
|
||
ERT is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY | ||
WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> | ||
for more details. | ||
*/ | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
#include <ert/util/test_util.h> | ||
#include <ert/util/time_t_vector.h> | ||
#include <ert/util/util.h> | ||
|
||
#include <ert/ecl/ecl_util.h> | ||
|
||
|
||
void test_date(int mday, int month , int year, int * year_offset) { | ||
time_t t0 = ecl_util_make_date__( mday , month , year , year_offset); | ||
time_t t1 = util_make_date( mday , month , year + *year_offset); | ||
test_assert_time_t_equal( t0 , t1 ); | ||
} | ||
|
||
|
||
void test_offset(int mday, int month , int year , int current_offset) { | ||
int year_offset; | ||
time_t t0 = ecl_util_make_date__( mday , month , year , &year_offset); | ||
time_t t1 = util_make_date( mday , month , year + current_offset); | ||
|
||
test_assert_time_t_equal(t0,t1); | ||
test_assert_int_equal( current_offset , year_offset ); | ||
} | ||
|
||
|
||
|
||
|
||
int main(int argc , char ** argv) { | ||
int year_offset; | ||
test_date(1,1,0 , &year_offset); | ||
test_offset(1,1,1000 , year_offset); | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. Isn't this slightly backwards?
exit(0)
frommain()
typically means "successful" whilemktime()
returns-1
if an error occurred.Also, is there a reason you're using POSIX interfaces when the standard
<time.h>
also providesmktime()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arggh: How to interleave answers in this interface?
I don't understand. Isn't this slightly backwards? exit(0) from main() typically means "successful" while mktime() returns -1 if an error occurred.
yes - it is backwards; I was waiting for that comment. Will fix before merging.
The POSIX thing was an oversight though. Will fix.
Thanks for the review.