From 8fcab8c9576155df4a26d90c952f57b74130a38d Mon Sep 17 00:00:00 2001 From: Vladislav Zarakovsky Date: Sun, 9 Dec 2018 14:58:48 +0300 Subject: [PATCH] Add missing Float#weeks method similar to Int#weeks --- spec/std/time/span_spec.cr | 1 + src/time/span.cr | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/spec/std/time/span_spec.cr b/spec/std/time/span_spec.cr index f0d32d10f86e..e801b29c9ce2 100644 --- a/spec/std/time/span_spec.cr +++ b/spec/std/time/span_spec.cr @@ -277,5 +277,6 @@ describe Time::Span do 1.hours.should eq(60.minutes) 1.week.should eq(7.days) 2.weeks.should eq(14.days) + 1.1.weeks.should eq(7.7.days) end end diff --git a/src/time/span.cr b/src/time/span.cr index a427bdcdc1d4..7b90b14326aa 100644 --- a/src/time/span.cr +++ b/src/time/span.cr @@ -476,6 +476,11 @@ struct Int end struct Float + # Returns a `Time::Span` of `self` weeks. + def weeks : Time::Span + (self * 7).days + end + # Returns a `Time::Span` of `self` days. def days : Time::Span (self * 24).hours