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
| Name | Type | Description |
|---|---|---|
year | Integer32 | Calendar year. |
month | Integer32 | Calendar month from 1 to 12. |
day_of_month | Integer32 | Day of month from 1 to 31. |
hour | Integer32 | Hour of day from 0 to 23. |
minute | Integer32 | Minute of hour from 0 to 59. |
second | Integer32 | Second of minute from 0 to 59. |
nanosecond | Integer32 | Nanosecond 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
| Name | Type | Description |
|---|---|---|
year | Integer32 | Calendar year (for example 2026). |
month | Integer32 | Month of year from 1 to 12. |
day | Integer32 | Day of month from 1 to 31. |
hour | Integer32 | Hour of day from 0 to 23. |
minute | Integer32 | Minute of hour from 0 to 59. |
second | Integer32 | Second of minute from 0 to 59. |
Return type
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
| Name | Type | Description |
|---|---|---|
iso_string | String | ISO-8601 civil datetime string without a zone offset. |
Return type
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
| Name | Type | Description |
|---|---|---|
input | String | Input text to parse. |
pattern | String | strptime-style format string: literals plus % conversion specifiers (see types module docs). |
Return type
Methods
dayOfMonth
- Stability:
stable
Returns the stored day-of-month field.
dayOfMonth(): Integer32
Parameters
This function does not take any parameters.
Return type
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
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
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
| Name | Type | Description |
|---|---|---|
pattern | String | strftime-style format string: literals plus % conversion specifiers (see types module docs). |
Return type
hour
- Stability:
stable
Returns the stored hour field.
hour(): Integer32
Parameters
This function does not take any parameters.
Return type
minusDuration
- Stability:
stable
Subtracts the duration in millisecond resolution using the same checked civil arithmetic as plusDuration.
minusDuration(duration: Duration): LocalDateTime
Parameters
| Name | Type | Description |
|---|---|---|
duration | Duration | Signed duration to subtract in millisecond resolution. |
Return type
minute
- Stability:
stable
Returns the stored minute field.
minute(): Integer32
Parameters
This function does not take any parameters.
Return type
month
- Stability:
stable
Returns the stored month field.
month(): Integer32
Parameters
This function does not take any parameters.
Return type
nanosecond
- Stability:
stable
Returns the stored sub-second nanosecond count.
nanosecond(): Integer32
Parameters
This function does not take any parameters.
Return type
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
| Name | Type | Description |
|---|---|---|
duration | Duration | Signed duration to add in millisecond resolution. |
Return type
second
- Stability:
stable
Returns the stored second field.
second(): Integer32
Parameters
This function does not take any parameters.
Return type
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
| Name | Type | Description |
|---|---|---|
timezone | TimeZone | IANA zone used to anchor this wall time on the UTC timeline. |
Return type
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
year
- Stability:
stable
Returns the stored year field without validating against a real calendar.
year(): Integer32
Parameters
This function does not take any parameters.