... | @@ -23,4 +23,16 @@ The column is automatically identified and the value is turned into `ActiveSuppo |
... | @@ -23,4 +23,16 @@ The column is automatically identified and the value is turned into `ActiveSuppo |
|
```ruby
|
|
```ruby
|
|
# Shows when you'll be finishing the course
|
|
# Shows when you'll be finishing the course
|
|
course.duration.from_now
|
|
course.duration.from_now
|
|
|
|
```
|
|
|
|
|
|
|
|
The value can be set in different manners:
|
|
|
|
```ruby
|
|
|
|
course.duration = 1.year # A new instance of ActiveSupport::Duration
|
|
|
|
course.duration = [1, 2, 3, 4, 5, 6] # A list of values for the given order Y-M-D H:M:S
|
|
|
|
course.duration = [1, 0, 0] # The list uses the right-most available positions, so this is H:M:S
|
|
|
|
course.duration = {days: 1, hours: 6} # You can use complex hash notation
|
|
|
|
course.duration = 'P1Y2M3DT4H5M6S' # It accepts ISO 8601 format, so form fields can cast to this type
|
|
|
|
|
|
|
|
course.duration = 259200
|
|
|
|
course.duration.parts.to_h == {days: 3} # It also converts any set value to the correct separated duration
|
|
``` |
|
``` |
|
|
|
\ No newline at end of file |