-
Notifications
You must be signed in to change notification settings - Fork 110
Added LocalTime.Formats.ISO_BASIC (ISO 8601 basic format) #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ISO 8601 specifies that the format for time-of-day includes a leading |
You are right, thanks for spotting this! I believe the same should also apply to LocalTime.Formats.ISO. Should I attempt to change it as well? |
The extended ISO format is allowed to omit the In fact, regarding usefulness: is |
I find it very useful, for example if one need to have a timestamp stored in a file name, in my case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! I don't see any problems with adding a LocalTime.Formats.ISO_BASIC
if it is indeed useful, but by that logic, it also makes sense to add LocalDateTime.Formats.ISO_BASIC
(which is the 20250415T065500
part in your message).
@@ -279,6 +279,23 @@ internal class LocalTimeFormat(override val actualFormat: CachedFormatStructure< | |||
} | |||
|
|||
// these are constants so that the formats are not recreated every time they are used | |||
internal val ISO_TIME_BASIC by lazy { | |||
LocalTimeFormat.build { | |||
char('T') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see internal val ISO_DATETIME
: our format is case-insensitive.
* | ||
* @sample kotlinx.datetime.test.samples.LocalTimeSamples.Formats.isoBasic | ||
*/ | ||
public val ISO_BASIC: DateTimeFormat<LocalTime> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add tests. Examples: LocalDateTimeFormatTest#testIso
, LocalDateFormatTest#testBasicIso
, etc.
/** | ||
* ISO 8601 basic format. | ||
* | ||
* Examples: `1234`, `123456`, `123456.789`, `123456.1234`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These examples are not valid for this format.
No description provided.