Skip to content

Commit

Permalink
Merge branch 'issue_33' into 'master'
Browse files Browse the repository at this point in the history
Issue 33

The setFromInfo method incorrectly accepted any length of year for the 'y' token, which is defined to be a two-digit year.  Modified the code to reflect the POSIX definition.

See merge request !35
  • Loading branch information
Jon Little committed Oct 27, 2015
2 parents a705bca + 1647518 commit 5becf65
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions core/lib/TimeHandling/CivilTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,20 @@ namespace gpstk
break;

case 'y':
switch( i->second.length() )
{
case 2:
year = asInt( i->second ) + 1900;
if( year < 1980 )
year += 100;
break;
case 3:
year = asInt( i->second ) + 1000;
if( year < 1980 )
year += 100;
break;
default:
year = asInt( i->second );
break;
};
// match the POSIX strptime() function:
/* Year within century. When a century is not
* otherwise specified, values in the range 69-99
* refer to years in the twentieth century (1969 to
* 1999 inclusive); values in the range 00-68 refer
* to years in the twenty-first century (2000 to
* 2068 inclusive). */
if( i->second.length() > 2)
return false;
year = asInt( i->second );
if (year >= 69)
year += 1900;
else
year += 2000;
break;

case 'm':
Expand Down

0 comments on commit 5becf65

Please sign in to comment.