@@ -85,6 +85,16 @@ public interface GlobalParserOptions {
85
85
* In notebooks, add `-opt-in=kotlin.uuid.ExperimentalUuidApi` to the compiler arguments.
86
86
*/
87
87
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
88
98
}
89
99
90
100
/* *
@@ -118,6 +128,11 @@ public interface GlobalParserOptions {
118
128
* NOTE: Interacting with a [Uuid][Uuid] in your code might require
119
129
* `@`[OptIn][OptIn]`(`[ExperimentalUuidApi][ExperimentalUuidApi]`::class)`.
120
130
* 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.
121
136
*/
122
137
public class ParserOptions (
123
138
public val locale : Locale ? = null ,
@@ -128,6 +143,7 @@ public class ParserOptions(
128
143
public val skipTypes : Set <KType >? = null ,
129
144
public val useFastDoubleParser : Boolean? = null ,
130
145
public val parseExperimentalUuid : Boolean? = null ,
146
+ public val parseExperimentalInstant : Boolean? = null ,
131
147
) {
132
148
133
149
/* * For binary compatibility. */
@@ -150,6 +166,7 @@ public class ParserOptions(
150
166
skipTypes = skipTypes,
151
167
useFastDoubleParser = useFastDoubleParser,
152
168
parseExperimentalUuid = null ,
169
+ parseExperimentalInstant = null ,
153
170
)
154
171
155
172
/* * For binary compatibility. */
@@ -170,6 +187,7 @@ public class ParserOptions(
170
187
skipTypes = null ,
171
188
useFastDoubleParser = null ,
172
189
parseExperimentalUuid = null ,
190
+ parseExperimentalInstant = null ,
173
191
)
174
192
175
193
/* * For binary compatibility. */
@@ -193,6 +211,7 @@ public class ParserOptions(
193
211
skipTypes = skipTypes,
194
212
useFastDoubleParser = useFastDoubleParser,
195
213
parseExperimentalUuid = null ,
214
+ parseExperimentalInstant = null ,
196
215
)
197
216
198
217
/* * For binary compatibility. */
@@ -214,6 +233,7 @@ public class ParserOptions(
214
233
skipTypes = skipTypes,
215
234
useFastDoubleParser = useFastDoubleParser,
216
235
parseExperimentalUuid = null ,
236
+ parseExperimentalInstant = null ,
217
237
)
218
238
219
239
internal fun getDateTimeFormatter (): DateTimeFormatter ? =
@@ -232,6 +252,7 @@ public class ParserOptions(
232
252
skipTypes : Set <KType >? = this.skipTypes,
233
253
useFastDoubleParser : Boolean? = this.useFastDoubleParser,
234
254
parseExperimentalUuid : Boolean? = this.parseExperimentalUuid,
255
+ parseExperimentalInstant : Boolean? = this.parseExperimentalInstant,
235
256
): ParserOptions =
236
257
ParserOptions (
237
258
locale = locale,
@@ -241,6 +262,7 @@ public class ParserOptions(
241
262
skipTypes = skipTypes,
242
263
useFastDoubleParser = useFastDoubleParser,
243
264
parseExperimentalUuid = parseExperimentalUuid,
265
+ parseExperimentalInstant = parseExperimentalInstant,
244
266
)
245
267
246
268
override fun equals (other : Any? ): Boolean {
@@ -256,6 +278,7 @@ public class ParserOptions(
256
278
if (nullStrings != other.nullStrings) return false
257
279
if (skipTypes != other.skipTypes) return false
258
280
if (parseExperimentalUuid != other.parseExperimentalUuid) return false
281
+ if (parseExperimentalInstant != other.parseExperimentalInstant) return false
259
282
260
283
return true
261
284
}
@@ -268,11 +291,12 @@ public class ParserOptions(
268
291
result = 31 * result + (nullStrings?.hashCode() ? : 0 )
269
292
result = 31 * result + (skipTypes?.hashCode() ? : 0 )
270
293
result = 31 * result + (parseExperimentalUuid?.hashCode() ? : 0 )
294
+ result = 31 * result + (parseExperimentalInstant?.hashCode() ? : 0 )
271
295
return result
272
296
}
273
297
274
298
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 )"
276
300
}
277
301
278
302
/* * @include [tryParseImpl] */
0 commit comments