Skip to content

Commit 57569da

Browse files
committed
BUG: fix an issue where adding two timestamps doesn't roll over to a new minute when seconds total to 60
1 parent ac2fc00 commit 57569da

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/time.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ export Timestamp
22

33
using Printf
44

5+
"""
6+
struct Timestamp
7+
8+
A simple time-keeping struct with space for minutes and (fractional) seconds.
9+
"""
510
mutable struct Timestamp
611
minutes::Int64
712
seconds::Real
@@ -25,7 +30,7 @@ end
2530
function Base.:+(x::Timestamp, y::Timestamp)
2631
total_minutes = x.minutes + y.minutes
2732
total_seconds = x.seconds + y.seconds
28-
if total_seconds > 60
33+
if total_seconds 60
2934
total_minutes += 1
3035
total_seconds -= 60
3136
end

0 commit comments

Comments
 (0)