Hyperlinkv0.8.0-beta.28

DateTime

DateTime.toPartsconsteffect/DateTime.ts:1717
(self: DateTime): DateTime.PartsWithWeekday

Gets the time-zone-adjusted parts of a DateTime as an object.

Details

The parts will be time zone adjusted if the DateTime is zoned.

Example (Reading DateTime parts)

import { DateTime } from "effect"

const dt = DateTime.makeUnsafe("2024-01-01T12:30:45.123Z")
const parts = DateTime.toParts(dt)

console.log(parts)
// {
//   year: 2024,
//   month: 1,
//   day: 1,
//   hours: 12,
//   minutes: 30,
//   seconds: 45,
//   millis: 123,
//   weekDay: 1 // Monday
// }
parts
export const toParts: (self: DateTime) => DateTime.PartsWithWeekday = Internal.toParts