Skip to content

Commit

Permalink
Implement Time#clone (crystal-lang#4174)
Browse files Browse the repository at this point in the history
* Implement Time#clone
  • Loading branch information
Sija authored and bcardiff committed Mar 23, 2017
1 parent 2744067 commit 204c94c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/std/time/time_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ describe Time do
time.epoch_ms.should eq(milliseconds)
end

it "clones" do
time = Time.now
(time == time.clone).should be_true
end

it "fields" do
Time::MaxValue.ticks.should eq(3155378975999999999)
Time::MinValue.ticks.should eq(0)
Expand Down
4 changes: 4 additions & 0 deletions src/time.cr
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ struct Time
new(UnixEpoch + milliseconds.to_i64 * Span::TicksPerMillisecond, Kind::Utc)
end

def clone
self
end

def +(other : Span)
add_ticks other.ticks
end
Expand Down

0 comments on commit 204c94c

Please sign in to comment.