Module: Slack::Utils
- Defined in:
- lib/slack/utils.rb
Class Method Summary collapse
-
.parse_slack_timestamp(slack_ts) ⇒ Object
Public: Extracts the timestamp information encoded in a Slack-style timestamp (e.g., “p1409120227001488”).
Class Method Details
.parse_slack_timestamp(slack_ts) ⇒ Object
Public: Extracts the timestamp information encoded in a Slack-style timestamp (e.g., “p1409120227001488”).
slack_ts - The Slack-tyle timestamp, e.g., “p1409120227001488”
Returns a Float containing the timestamp in UNIX time w/ milliseconds.
Examples
("p1409120227001488") # => 1409120227.001488
("s1409192267000101") # => 1409192267.000101
16 17 18 19 20 21 22 23 |
# File 'lib/slack/utils.rb', line 16 def self.(slack_ts) if match = slack_ts.match(/\A[a-z](\d+)\z/i) match[1].to_f / 10**6 else fail ArgumentError, "argument does not look like a Slack timestamp (got `#{slack_s}')" end end |