# endOfTime

Industry: Core

## Signature

```ts
endOfTime(value: string, unit: EndOfTimeUnit, optionsArg?: { fractionalSecondDigits?: FractionalDigit; }): string
```

Return the end of the specified time `unit` for a given ISO 8601 time string.

- `unit` accepts the singular or plural name (`"hour"` or `"hours"`), as Temporal does.
- Returns "" for invalid inputs.
- **Compatibility:** before 1.16.0 the default printed only the digits the unit names — none for `second` and coarser, 3 for `millisecond`, 6 for `microsecond` — which wrote a moment earlier than the end. Pass that `fractionalSecondDigits` to keep the previous string.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | ISO 8601 time string |
| `unit` | `EndOfTimeUnit` | EndOfTimeUnit to specify the unit for the end |

## Options

**optionsArg**

How the result is written

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `fractionalSecondDigits?` | `0` \| `1` \| `2` \| `3` \| `4` \| `5` \| `6` \| `7` \| `"auto"` \| `8` \| `9` ([`FractionalDigit`](/gmt/reference/types/FractionalDigit/)) | `9` | The number of fractional-second digits the result is written with, `0` to `9`, or `"auto"` to drop trailing zeros. Fewer than 9 digits truncate the string, as Temporal's `toString` does, so it names a moment before the end. |

## Returns

ISO 8601 string representing the end of the specified unit, or "" on invalid input

## Types

### EndOfTimeUnit

Units `endOfTime` accepts: a Temporal time unit, or `"day"` for the last moment of the day, each singular or plural.

```ts
import type { EndOfTimeUnit } from "@northguild/gmt";
```

```ts
"days" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds" | "day" | TimeUnit
```

## Related types

- [`FractionalDigit`](/gmt/reference/types/FractionalDigit/)

## Examples

```ts
import { endOfTime } from "@northguild/gmt/plain/calculate";

endOfTime("12:34:56", "hour") // "12:59:59.999999999"
```

## Source

[plain/calculate/endOfTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/calculate/endOfTime.ts)
