Skip to content

Commit

Permalink
Fix off-by-one error in time printing
Browse files Browse the repository at this point in the history
Was printing e.g. "day 0" when it was "day 1".
  • Loading branch information
jbytheway committed Apr 18, 2020
1 parent 08e162b commit 1363e8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ std::string to_string( const time_point &p )
//~ 1 is the year, 2 is the day (of the *year*), 3 is the time of the day in its usual format
return string_format( _( "Year %1$d, day %2$d %3$s" ), year, day, time );
} else {
const int day = day_of_season<int>( p );
const int day = day_of_season<int>( p ) + 1;
//~ 1 is the year, 2 is the season name, 3 is the day (of the season), 4 is the time of the day in its usual format
return string_format( _( "Year %1$d, %2$s, day %3$d %4$s" ), year,
calendar::name_season( season_of_year( p ) ), day, time );
Expand Down
6 changes: 3 additions & 3 deletions tests/stats_tracker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,16 @@ TEST_CASE( "achievments_tracker", "[stats]" )
if( time_since_game_start < 1_minutes ) {
CHECK( a.ui_text_for( achievements_completed.at( a_kill_zombie ) ) ==
"<color_c_light_green>One down, billions to go…</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 0 0000.30</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 1 0000.30</color>\n"
" <color_c_green>1/1 Number of zombies killed</color>\n" );
CHECK( a.ui_text_for( achievements_completed.at( a_kill_in_first_minute ) ) ==
"<color_c_light_green>Rude awakening</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 0 0000.30</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 1 0000.30</color>\n"
" <color_c_green>1/1 Number of monsters killed</color>\n" );
} else {
CHECK( a.ui_text_for( achievements_completed.at( a_kill_zombie ) ) ==
"<color_c_light_green>One down, billions to go…</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 0 0010.00</color>\n"
" <color_c_light_green>Completed Year 1, Spring, day 1 0010.00</color>\n"
" <color_c_green>1/1 Number of zombies killed</color>\n" );
CHECK( !achievements_completed.count( a_kill_in_first_minute ) );
CHECK( a.ui_text_for( &*a_kill_in_first_minute ) ==
Expand Down

0 comments on commit 1363e8d

Please sign in to comment.