-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathelapsed_time.rb
More file actions
38 lines (35 loc) · 1.13 KB
/
elapsed_time.rb
File metadata and controls
38 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
module Strava
module Models
module Mixins
#
# Provides elapsed time formatting methods.
#
# Elapsed time is the total time from start to finish of an activity, including
# stopped/paused time. This mixin adds the elapsed_time property and a helper
# method to format it as hours/minutes/seconds.
#
# @example Using elapsed time helpers
# activity = client.activity(1234567890)
# puts activity.elapsed_time # => 4200 (seconds)
# puts activity.elapsed_time_in_hours_s # => "1h10m"
#
module ElapsedTime
extend ActiveSupport::Concern
include TimeInHours
included do
# @return [Integer] Total elapsed time in seconds (includes stopped time)
property 'elapsed_time'
end
#
# Returns formatted elapsed time as hours, minutes, and seconds.
#
# @return [String, nil] Formatted time string (e.g., "1h23m45s", "45m30s", "30s")
#
def elapsed_time_in_hours_s
time_in_hours_s elapsed_time
end
end
end
end
end