... | ... | @@ -36,3 +36,9 @@ course.duration = 'P1Y2M3DT4H5M6S' # It accepts ISO 8601 format, so form f |
|
|
course.duration = 259200
|
|
|
course.duration.parts.to_h == {days: 3} # It also converts any set value to the correct separated duration
|
|
|
```
|
|
|
|
|
|
On your views, you can use `I18n.locale` to transform it to a readable text:
|
|
|
```html
|
|
|
<p>Course duration: <%= l @course.duration %></p>
|
|
|
<!-- Will print something like 'Course duration: 1 year, 2 months, and 3 days' -->
|
|
|
``` |
|
|
\ No newline at end of file |