Skip to content

Commit 4d50ff8

Browse files
authored
Fix typo in comment, remove unnecessary escaping, and simplify toms (#45885)
1 parent 8cc5445 commit 4d50ff8

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

stdlib/Dates/src/periods.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ coarserperiod(::Type{Month}) = (Year, 12)
160160
CompoundPeriod
161161
162162
A `CompoundPeriod` is useful for expressing time periods that are not a fixed multiple of
163-
smaller periods. For example, \"a year and a day\" is not a fixed number of days, but can
163+
smaller periods. For example, "a year and a day" is not a fixed number of days, but can
164164
be expressed using a `CompoundPeriod`. In fact, a `CompoundPeriod` is automatically
165165
generated by addition of different period types, e.g. `Year(1) + Day(1)` produces a
166166
`CompoundPeriod` result.
@@ -482,7 +482,7 @@ const zero_or_fixedperiod_seed = UInt === UInt64 ? 0x5b7fc751bba97516 : 0xeae0fd
482482
const nonzero_otherperiod_seed = UInt === UInt64 ? 0xe1837356ff2d2ac9 : 0x170d1b00
483483
otherperiod_seed(x::OtherPeriod) = iszero(value(x)) ? zero_or_fixedperiod_seed : nonzero_otherperiod_seed
484484
# tons() will overflow for periods longer than ~300,000 years, implying a hash collision
485-
# which is relatively harmless given how infrequent such periods should appear
485+
# which is relatively harmless given how infrequently such periods should appear
486486
Base.hash(x::FixedPeriod, h::UInt) = hash(tons(x), h + zero_or_fixedperiod_seed)
487487
# Overflow can also happen here for really long periods (~8e17 years)
488488
Base.hash(x::Year, h::UInt) = hash(12 * value(x), h + otherperiod_seed(x))
@@ -511,11 +511,7 @@ toms(c::Millisecond) = value(c)
511511
toms(c::Second) = 1000 * value(c)
512512
toms(c::Minute) = 60000 * value(c)
513513
toms(c::Hour) = 3600000 * value(c)
514-
toms(c::Day) = 86400000 * value(c)
515-
toms(c::Week) = 604800000 * value(c)
516-
toms(c::Month) = 86400000.0 * 30.436875 * value(c)
517-
toms(c::Quarter) = 86400000.0 * 91.310625 * value(c)
518-
toms(c::Year) = 86400000.0 * 365.2425 * value(c)
514+
toms(c::Period) = 86400000 * days(c)
519515
toms(c::CompoundPeriod) = isempty(c.periods) ? 0.0 : Float64(sum(toms, c.periods))
520516
tons(x) = toms(x) * 1000000
521517
tons(x::Microsecond) = value(x) * 1000

0 commit comments

Comments
 (0)