# Operations with time duration

**URL:** https://discourse.julialang.org/t/operations-with-time-duration/64983
**Category:** General Usage
**Tags:** dates, time
**Created:** [July 20, 2021, 1:58pm UTC](https://discourse.julialang.org/t/operations-with-time-duration/64983 "2021-07-20T13:58:31Z")
**Posts on this page:** 1
**Showing post:** 22

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [July 22, 2021, 4:43pm UTC](https://discourse.julialang.org/t/operations-with-time-duration/64983/22 "2021-07-22T16:43:11Z")

</div>

The reason for deleting the post was lack of confidence in the code.  
The review below seems better:

```julia
using Dates
import Base: / 
/(t::Dates.CompoundPeriod, x::Real) = canonicalize(Dates.CompoundPeriod(Millisecond(round(Int64,Dates.toms(t)/x))))

t = Hour(26) + Minute(3) + Second(5)
t/5
5 hours, 12 minutes, 37 seconds

t = Hour(1) + Minute(5) + Second(2)
t/5
13 minutes, 400 milliseconds

```

_NB: code based on this_ [post](https://discourse.julialang.org/t/how-to-convert-period-in-milisecond-to-minutes-seconds-hour-etc/2423/14) _and on this_ [one](https://discourse.julialang.org/t/overloading-base-operator-from-module/621/3)

---

_[View the full topic](https://discourse.julialang.org/t/operations-with-time-duration/64983)._
