Skip to content

Commit

Permalink
Remove String.toSomething
Browse files Browse the repository at this point in the history
Fixes #339
  • Loading branch information
dkhalanskyjb committed Jan 26, 2024
1 parent a6d0abb commit a63571f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 38 deletions.
20 changes: 4 additions & 16 deletions core/common/src/DateTimePeriod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,9 @@ public sealed class DateTimePeriod {
}

/**
* Parses the ISO-8601 duration representation as a [DateTimePeriod].
*
* See [DateTimePeriod.parse] for examples.
*
* @throws IllegalArgumentException if the text cannot be parsed or the boundaries of [DateTimePeriod] are exceeded.
*
* @see DateTimePeriod.parse
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("DateTimePeriod.parse(this)"), DeprecationLevel.WARNING)
public fun String.toDateTimePeriod(): DateTimePeriod = DateTimePeriod.parse(this)

/**
Expand Down Expand Up @@ -358,16 +353,9 @@ public class DatePeriod internal constructor(
}

/**
* Parses the ISO-8601 duration representation as a [DatePeriod].
*
* This function is equivalent to [DateTimePeriod.parse], but will fail if any of the time components are not
* zero.
*
* @throws IllegalArgumentException if the text cannot be parsed, the boundaries of [DatePeriod] are exceeded,
* or any time components are not zero.
*
* @see DateTimePeriod.parse
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("DatePeriod.parse(this)"), DeprecationLevel.WARNING)
public fun String.toDatePeriod(): DatePeriod = DatePeriod.parse(this)

private class DateTimePeriodImpl(
Expand Down
8 changes: 2 additions & 6 deletions core/common/src/Instant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,9 @@ public val Instant.isDistantFuture: Boolean
get() = this >= Instant.DISTANT_FUTURE

/**
* Converts this string representing an instant in ISO-8601 format including date and time components and
* the time zone offset to an [Instant] value.
*
* See [Instant.parse] for examples of instant string representations and discussion of leap seconds.
*
* @throws IllegalArgumentException if the text cannot be parsed or the boundaries of [Instant] are exceeded.
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("Instant.parse(this)"), DeprecationLevel.WARNING)
public fun String.toInstant(): Instant = Instant.parse(this)

/**
Expand Down
7 changes: 2 additions & 5 deletions core/common/src/LocalDate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,9 @@ public fun LocalDate.Companion.parse(input: CharSequence, format: DateTimeFormat
format.parse(input)

/**
* Converts this string representing a date in ISO-8601 format to a [LocalDate] value.
*
* See [LocalDate.parse] for examples of local date string representations.
*
* @throws IllegalArgumentException if the text cannot be parsed or the boundaries of [LocalDate] are exceeded.
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("LocalDate.parse(this)"), DeprecationLevel.WARNING)
public fun String.toLocalDate(): LocalDate = LocalDate.parse(this)

/**
Expand Down
8 changes: 2 additions & 6 deletions core/common/src/LocalDateTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,8 @@ public fun LocalDateTime.Companion.parse(input: CharSequence, format: DateTimeFo
format.parse(input)

/**
* Converts this string representing a date/time value in ISO-8601 format including date and time components
* but without any time zone component to a [LocalDateTime] value.
*
* See [LocalDateTime.parse] for examples of date/time string representations.
*
* @throws IllegalArgumentException if the text cannot be parsed or the boundaries of [LocalDateTime] are exceeded.
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("LocalDateTime.parse(this)"), DeprecationLevel.WARNING)
public fun String.toLocalDateTime(): LocalDateTime = LocalDateTime.parse(this)

7 changes: 2 additions & 5 deletions core/common/src/LocalTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,9 @@ public fun LocalTime.Companion.parse(input: CharSequence, format: DateTimeFormat
format.parse(input)

/**
* Converts this string representing a time value in ISO-8601 format to a [LocalTime] value.
*
* See [LocalTime.parse] for examples of time string representations.
*
* @throws IllegalArgumentException if the text cannot be parsed or the boundaries of [LocalTime] are exceeded.
* @suppress
*/
@Deprecated("Removed to support more idiomatic code. See https://github.com/Kotlin/kotlinx-datetime/issues/339", ReplaceWith("LocalTime.parse(this)"), DeprecationLevel.WARNING)
public fun String.toLocalTime(): LocalTime = LocalTime.parse(this)

/**
Expand Down

0 comments on commit a63571f

Please sign in to comment.