Formats a timestamp as a localized string or as relative text that auto-updates in the user's browser.
Name | Type | Default | Description |
---|---|---|---|
datetime | Time | N/A | The time to be formatted. |
tense | Symbol | :auto | Which tense to use. One of :auto , :future , or :past . |
prefix | sring | nil | What to prefix the relative ime display with. |
second | Symbol | SECOND_DEFAULT | What format seconds should take. One of nil , :numeric , or :two_digit . |
minute | Symbol | MINUTE_DEFAULT | What format minues should take. One of nil , :numeric , or :two_digit . |
hour | Symbol | HOUR_DEFAULT | What format hours should take. One of nil , :numeric , or :two_digit . |
weekday | Symbol | WEEKDAY_DEFAULT | What format weekdays should take. One of nil , :long , :narrow , or :short . |
day | Symbol | DAY_DEFAULT | What format days should take. One of nil , :numeric , or :two_digit . |
month | Symbol | MONTH_DEFAULT | What format months should take. One of nil , :long , :narrow , :numeric , :short , or :two_digit . |
year | Symbol | YEAR_DEFAULT | What format years should take. One of nil , :numeric , or :two_digit . |
time_zone_name | Symbol | TIMEZONENAME_DEFAULT | What format the time zone should take. One of nil , :long , :long_generic , :long_offset , :short , :short_generic , or :short_offset . |
threshold | string | nil | The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute. |
precision | Symbol | PRECISION_DEFAULT | The precision elapsed time should display. One of nil , :day , :hour , :minute , :month , :second , or :year . |
format | Symbol | nil | The format the display should take. One of :auto , :elapsed , or :micro . |
format_style | Symbol | nil | The format the display should take. One of nil , :long , :narrow , or :short . |
lang | string | nil | The language to use. |
title | string | nil | Provide a custom title to the element. |
system_arguments | Hash | N/A | System arguments |
<%= render(Primer::Beta::RelativeTime.new(datetime: Time.at(628232400))) %>
<%= render(Primer::Beta::RelativeTime.new(datetime: Time.at(628232400), tense: :past)) %>
<%= render(Primer::Beta::RelativeTime.new(datetime: Time.at(628232400), format: :elapsed)) %>