# getOrdinalDate

Industry: Core

## Signature

```ts
getOrdinalDate(value: string): { year: number; dayOfYear: number; } | null
```

Return the ISO 8601 ordinal date — calendar year and day of year — for `value`.

- Unlike `getIsoWeekDate`, whose year is the week-numbering year, an ordinal date never disagrees with the calendar year it is written beside.
- `value` must be zoneless — an ISO date or datetime, as `isValidIsoDateLike` accepts. See `getIsoWeekDate` for why a moment is not accepted here.
- Returns null on invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | zoneless ISO 8601 date or datetime string (e.g. "2024-06-15") |

## Returns

&#123; year, dayOfYear &#125;, or null on invalid input

**Members**

| Member | Type | Description |
| --- | --- | --- |
| `year` | `number` | The calendar year of the date. It is not the ISO 8601 week-numbering year, so it always matches the year written in `value`. |
| `dayOfYear` | `number` | The 1-based day of that year, the ISO 8601 ordinal day: 1 is January 1, and December 31 is 365, or 366 in a leap year. |

## Examples

```ts
import { getOrdinalDate } from "@northguild/gmt/calendar/calculate";

getOrdinalDate("2024-01-01") // { year: 2024, dayOfYear: 1 }
```

## Source

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