Skip to content

Commit c1760be

Browse files
committed
Duration: Support duration values of 70y and longer
1 parent 38c73c9 commit c1760be

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/Duration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ bool Duration::parse_units (Pig& pig)
324324
if (durations[i].unit == unit &&
325325
durations[i].standalone)
326326
{
327-
_period = static_cast <int> (durations[i].seconds);
327+
_period = static_cast <time_t> (durations[i].seconds);
328328
return true;
329329
}
330330
}
@@ -370,7 +370,7 @@ bool Duration::parse_units (Pig& pig)
370370
if (durations[i].unit == unit)
371371
{
372372
seconds = durations[i].seconds;
373-
_period = static_cast <int> (number * static_cast <double> (seconds));
373+
_period = static_cast <time_t> (number * static_cast <double> (seconds));
374374
return true;
375375
}
376376
}
@@ -526,7 +526,7 @@ int Duration::minutes () const
526526
}
527527

528528
////////////////////////////////////////////////////////////////////////////////
529-
int Duration::seconds () const
529+
time_t Duration::seconds () const
530530
{
531531
return _period;
532532
}

src/Duration.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ class Duration
5858
int days () const;
5959
int hours () const;
6060
int minutes () const;
61-
int seconds () const;
61+
time_t seconds () const;
6262

6363
private:
6464
void clear ();
6565
void resolve ();
6666
std::string dump () const;
6767

6868
public:
69-
int _year {0};
70-
int _month {0};
71-
int _weeks {0};
72-
int _day {0};
73-
int _hours {0};
74-
int _minutes {0};
75-
int _seconds {0};
76-
time_t _period {0};
69+
int _year {0};
70+
int _month {0};
71+
int _weeks {0};
72+
int _day {0};
73+
int _hours {0};
74+
int _minutes {0};
75+
time_t _seconds {0};
76+
time_t _period {0};
7777
};
7878

7979
#endif

test/duration.t.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void testParse (
3939
int in_day,
4040
int in_hours,
4141
int in_minutes,
42-
int in_seconds,
42+
time_t in_seconds,
4343
time_t in_period,
4444
const std::string& output,
4545
const std::string& hours,

0 commit comments

Comments
 (0)