Skip to content

Commit

Permalink
Merge pull request #291 from avandecreme/fix_timeoffset
Browse files Browse the repository at this point in the history
Accept timezones really far from UTC
  • Loading branch information
fbergmann committed Jan 9, 2023
2 parents 226c867 + f2a6472 commit 671f01e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sbml/annotation/Date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ Date::setSignOffset (unsigned int sign)
int
Date::setHoursOffset (unsigned int hour)
{
if (/*hour < 0 ||*/ hour > 12)
if (/*hour < 0 ||*/ hour > 14)
{
mHoursOffset = 0;
parseDateNumbersToString();
Expand Down Expand Up @@ -645,7 +645,8 @@ Date::representsValidDate()
getMinute() > 59 ||
getSecond() > 59 ||
getSignOffset() > 1 ||
getHoursOffset() > 11 ||
(getSignOffset() == 0 && getHoursOffset() > 12) ||
(getSignOffset() == 1 && getHoursOffset() > 14) ||
getMinutesOffset() > 59)
{
valid = false;
Expand Down
18 changes: 18 additions & 0 deletions src/sbml/annotation/test/TestModelHistory.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ START_TEST (test_Date_getDateAsString)
}
END_TEST

START_TEST (test_Date_representsValidDate)
{
Date_t * date = Date_createFromValues(2023, 1, 3, 18, 0, 23, 0, 12, 0);

fail_unless(date != NULL);
fail_unless(Date_representsValidDate(date));

Date_setHoursOffset(date, 14);
fail_unless(!Date_representsValidDate(date));

Date_setSignOffset(date, 1);
fail_unless(Date_representsValidDate(date));

Date_free(date);
}
END_TEST

START_TEST(test_ModelCreator_create)
{
ModelCreator_t * mc = ModelCreator_create();
Expand Down Expand Up @@ -427,6 +444,7 @@ create_suite_ModelHistory (void)
tcase_add_test( tcase, test_Date_createFromString );
tcase_add_test( tcase, test_Date_setters );
tcase_add_test( tcase, test_Date_getDateAsString );
tcase_add_test( tcase, test_Date_representsValidDate );
tcase_add_test( tcase, test_ModelCreator_create );
tcase_add_test( tcase, test_ModelCreator_setters );
tcase_add_test( tcase, test_ModelHistory_create );
Expand Down

0 comments on commit 671f01e

Please sign in to comment.