TimeReferenceNew · 0.744
Duration.FromSeconds
Create a duration from seconds.
Details#
Converts a number of seconds into a Duration. Its fields provide the total value in each supported unit. Negative values represent negative durations. Fractional inputs are accepted, but precision stops at whole nanoseconds. Months and years are fixed average units rather than calendar intervals.
Fields Duration#
| Field | Type | Meaning |
|---|---|---|
Nanoseconds | number | The total duration in nanoseconds, including a fractional part where applicable. |
Microseconds | number | The total duration in microseconds, including a fractional part where applicable. |
Milliseconds | number | The total duration in milliseconds, including a fractional part where applicable. |
Seconds | number | The total duration in seconds, including a fractional part where applicable. |
Minutes | number | The total duration in minutes, including a fractional part where applicable. |
Hours | number | The total duration in hours, including a fractional part where applicable. |
Days | number | The total duration in days, including a fractional part where applicable. |
Months | number | The total duration in months, including a fractional part where applicable. One month is the fixed average of 30.436875 days, not a calendar month. |
Years | number | The total duration in years, including a fractional part where applicable. One year is the fixed average of 365.2425 days, not a calendar year. |
Signature#
Duration.FromSeconds(amount: number): DurationParameters#
| Parameter | Type | Description |
|---|---|---|
amount | number | The duration in seconds; finite, representable values only. |
Returns#
A Duration. A nonnumeric argument raises an error; out-of-range or non-finite values have no documented result.
Examples#
Local example
local duration = Duration.FromSeconds(1.5)
print(duration.Seconds)Notes#
- Each field reports the entire duration in that unit, not a separate component. For example, 90 seconds has Seconds = 90 and Minutes = 1.5.
- Fractional nanoseconds are discarded toward zero. Numeric results can lose precision for large durations, especially when reading nanoseconds. Use finite inputs and keep the converted duration within the supported numeric range.
- Months and years use fixed averages of 30.436875 and 365.2425 days. These values do not perform calendar arithmetic or account for varying month lengths.