Skip to main content

LocalDateTime

  • Stability: stable
  • Since: 0.1.0

Represents local calendar fields without identifying the zone or offset that makes them an absolute instant.

  • Qualified id: com.dataspine.datetime.LocalDateTime@1
  • Kind: struct

Properties

NameTypeDescription
yearInteger32Calendar year.
monthInteger32Calendar month from 1 to 12.
day_of_monthInteger32Day of month from 1 to 31.
hourInteger32Hour of day from 0 to 23.
minuteInteger32Minute of hour from 0 to 59.
secondInteger32Second of minute from 0 to 59.
nanosecondInteger32Nanosecond fraction within the second.

Static methods

of

  • Stability: stable

Builds a value with nanoseconds set to zero. Invalid calendar combinations are not rejected here; they surface when you parse, format, add duration, or project to an instant.

of(year: Integer32, month: Integer32, day: Integer32, hour: Integer32, minute: Integer32, second: Integer32): LocalDateTime

Parameters

NameTypeDescription
yearInteger32Calendar year (for example 2026).
monthInteger32Month of year from 1 to 12.
dayInteger32Day of month from 1 to 31.
hourInteger32Hour of day from 0 to 23.
minuteInteger32Minute of hour from 0 to 59.
secondInteger32Second of minute from 0 to 59.

Return type

LocalDateTime

parse

  • Stability: stable

Parses common ISO 8601 civil forms: calendar date, optional T separator, clock fields, optional fractional seconds—without a zone offset. The exact accepted grammar matches the datetime runtime's zone-less parser. On failure returns DateTimeError::ParseError together with a zeroed placeholder value.

parse(iso_string: String): LocalDateTime

Parameters

NameTypeDescription
iso_stringStringISO-8601 civil datetime string without a zone offset.

Return type

LocalDateTime

parsePattern

  • Stability: stable

Matches input against pattern using POSIX-style % directives (see types module docs). On success the resulting civil date and clock fields are stored in this zone-less value. On failure returns DateTimeError::ParseError and a placeholder local date-time.

parsePattern(input: String, pattern: String): LocalDateTime

Parameters

NameTypeDescription
inputStringInput text to parse.
patternStringstrptime-style format string: literals plus % conversion specifiers (see types module docs).

Return type

LocalDateTime

Methods

dayOfMonth

  • Stability: stable

Returns the stored day-of-month field.

dayOfMonth(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

dayOfWeek

  • Stability: stable

Interprets the stored fields as a proleptic Gregorian local date-time and returns the ISO weekday with Monday as 1 through Sunday as 7.

dayOfWeek(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

dayOfYear

  • Stability: stable

Ordinal day of year (1–366) for the stored civil fields under the same proleptic Gregorian rules as the other calendar accessors.

dayOfYear(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

format

  • Stability: stable

Formats using POSIX-style % directives (see types module docs). Invalid stored field combinations surface as InvalidDateTime in the optional slot.

format(pattern: String): String

Parameters

NameTypeDescription
patternStringstrftime-style format string: literals plus % conversion specifiers (see types module docs).

Return type

String

hour

  • Stability: stable

Returns the stored hour field.

hour(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

minusDuration

  • Stability: stable

Subtracts the duration in millisecond resolution using the same checked civil arithmetic as plusDuration.

minusDuration(duration: Duration): LocalDateTime

Parameters

NameTypeDescription
durationDurationSigned duration to subtract in millisecond resolution.

Return type

LocalDateTime

minute

  • Stability: stable

Returns the stored minute field.

minute(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

month

  • Stability: stable

Returns the stored month field.

month(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

nanosecond

  • Stability: stable

Returns the stored sub-second nanosecond count.

nanosecond(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

plusDuration

  • Stability: stable

Adds the duration in millisecond resolution using checked civil arithmetic on the proleptic Gregorian timeline; overflow or impossible local times surface as InvalidDateTime.

plusDuration(duration: Duration): LocalDateTime

Parameters

NameTypeDescription
durationDurationSigned duration to add in millisecond resolution.

Return type

LocalDateTime

second

  • Stability: stable

Returns the stored second field.

second(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

toInstant

  • Stability: stable

Combines civil fields with the named IANA zone, using that zone's rules (including DST) from the database bundled with the datetime runtime to obtain a unique UTC instant when possible.

toInstant(timezone: TimeZone): Instant

Parameters

NameTypeDescription
timezoneTimeZoneIANA zone used to anchor this wall time on the UTC timeline.

Return type

Instant

toIsoString

  • Stability: stable

Returns the canonical ISO 8601 extended text for this civil value (date, T clock, fractional seconds when non-zero), as produced by the datetime runtime.

toIsoString(): String

Parameters

This function does not take any parameters.

Return type

String

year

  • Stability: stable

Returns the stored year field without validating against a real calendar.

year(): Integer32

Parameters

This function does not take any parameters.

Return type

Integer32

Back to Datetime