@@ -85,6 +85,16 @@ public interface GlobalParserOptions {
8585 * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments.
8686 */
8787 public var parseExperimentalUuid: Boolean
88+
89+ /* *
90+ * Whether to allow parsing to the experimental [kotlin.time.Instant] type.
91+ * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350).
92+ *
93+ * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require
94+ * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`.
95+ * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments.
96+ */
97+ public var parseExperimentalInstant: Boolean
8898}
8999
90100/* *
@@ -118,6 +128,11 @@ public interface GlobalParserOptions {
118128 * NOTE: Interacting with a [Uuid][Uuid] in your code might require
119129 * `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`.
120130 * In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments.
131+ * @param parseExperimentalInstant whether to allow parsing to the experimental [kotlin.time.Instant] type.
132+ * By default, this is false and instants are recognized as the deprecated [kotlinx.datetime.Instant] type (#1350).
133+ * NOTE: Interacting with an [Instant][kotlin.time.Instant] in your code might require
134+ * `@`[OptIn][OptIn]`(`[ExperimentalTime][kotlin.time.ExperimentalTime]`::class)`.
135+ * In notebooks, add `-opt-in=kotlin.time.ExperimentalTime` to the compiler arguments.
121136 */
122137public class ParserOptions (
123138 public val locale : Locale ? = null ,
@@ -128,6 +143,7 @@ public class ParserOptions(
128143 public val skipTypes : Set <KType >? = null ,
129144 public val useFastDoubleParser : Boolean? = null ,
130145 public val parseExperimentalUuid : Boolean? = null ,
146+ public val parseExperimentalInstant : Boolean? = null ,
131147) {
132148
133149 /* * For binary compatibility. */
@@ -150,6 +166,7 @@ public class ParserOptions(
150166 skipTypes = skipTypes,
151167 useFastDoubleParser = useFastDoubleParser,
152168 parseExperimentalUuid = null ,
169+ parseExperimentalInstant = null ,
153170 )
154171
155172 /* * For binary compatibility. */
@@ -170,6 +187,7 @@ public class ParserOptions(
170187 skipTypes = null ,
171188 useFastDoubleParser = null ,
172189 parseExperimentalUuid = null ,
190+ parseExperimentalInstant = null ,
173191 )
174192
175193 /* * For binary compatibility. */
@@ -193,6 +211,7 @@ public class ParserOptions(
193211 skipTypes = skipTypes,
194212 useFastDoubleParser = useFastDoubleParser,
195213 parseExperimentalUuid = null ,
214+ parseExperimentalInstant = null ,
196215 )
197216
198217 /* * For binary compatibility. */
@@ -214,6 +233,7 @@ public class ParserOptions(
214233 skipTypes = skipTypes,
215234 useFastDoubleParser = useFastDoubleParser,
216235 parseExperimentalUuid = null ,
236+ parseExperimentalInstant = null ,
217237 )
218238
219239 internal fun getDateTimeFormatter (): DateTimeFormatter ? =
@@ -232,6 +252,7 @@ public class ParserOptions(
232252 skipTypes : Set <KType >? = this.skipTypes,
233253 useFastDoubleParser : Boolean? = this.useFastDoubleParser,
234254 parseExperimentalUuid : Boolean? = this.parseExperimentalUuid,
255+ parseExperimentalInstant : Boolean? = this.parseExperimentalInstant,
235256 ): ParserOptions =
236257 ParserOptions (
237258 locale = locale,
@@ -241,6 +262,7 @@ public class ParserOptions(
241262 skipTypes = skipTypes,
242263 useFastDoubleParser = useFastDoubleParser,
243264 parseExperimentalUuid = parseExperimentalUuid,
265+ parseExperimentalInstant = parseExperimentalInstant,
244266 )
245267
246268 override fun equals (other : Any? ): Boolean {
@@ -256,6 +278,7 @@ public class ParserOptions(
256278 if (nullStrings != other.nullStrings) return false
257279 if (skipTypes != other.skipTypes) return false
258280 if (parseExperimentalUuid != other.parseExperimentalUuid) return false
281+ if (parseExperimentalInstant != other.parseExperimentalInstant) return false
259282
260283 return true
261284 }
@@ -268,11 +291,12 @@ public class ParserOptions(
268291 result = 31 * result + (nullStrings?.hashCode() ? : 0 )
269292 result = 31 * result + (skipTypes?.hashCode() ? : 0 )
270293 result = 31 * result + (parseExperimentalUuid?.hashCode() ? : 0 )
294+ result = 31 * result + (parseExperimentalInstant?.hashCode() ? : 0 )
271295 return result
272296 }
273297
274298 override fun toString (): String =
275- " ParserOptions(locale=$locale , dateTimeFormatter=$dateTimeFormatter , dateTimePattern=$dateTimePattern , nullStrings=$nullStrings , skipTypes=$skipTypes , useFastDoubleParser=$useFastDoubleParser , parseExperimentalUuid=$parseExperimentalUuid )"
299+ " ParserOptions(locale=$locale , dateTimeFormatter=$dateTimeFormatter , dateTimePattern=$dateTimePattern , nullStrings=$nullStrings , skipTypes=$skipTypes , useFastDoubleParser=$useFastDoubleParser , parseExperimentalUuid=$parseExperimentalUuid , parseExperimentalInstant= $parseExperimentalInstant )"
276300}
277301
278302/* * Tries to parse a column of strings into a column of a different type.
0 commit comments