5
5
6
6
package kotlinx.datetime.format
7
7
8
+ import kotlinx.datetime.*
9
+ import kotlinx.datetime.internal.*
8
10
import kotlinx.datetime.internal.format.*
9
11
10
12
/* *
@@ -18,6 +20,82 @@ public sealed interface DateTimeFormatBuilder {
18
20
* and when parsing, the string is expected to be present in the input verbatim.
19
21
*/
20
22
public fun chars (value : String )
23
+
24
+ /* *
25
+ * Functions specific to the date-time format builders containing the local-date fields.
26
+ */
27
+ public sealed interface WithDate : DateTimeFormatBuilder {
28
+ /* *
29
+ * A year number.
30
+ *
31
+ * By default, for years [-9999..9999], it's formatted as a decimal number, zero-padded to four digits, though
32
+ * this padding can be disabled or changed to space padding by passing [padding].
33
+ * For years outside this range, it's formatted as a decimal number with a leading sign, so the year 12345
34
+ * is formatted as "+12345".
35
+ */
36
+ public fun year (padding : Padding = Padding .ZERO )
37
+
38
+ /* *
39
+ * The last two digits of the ISO year.
40
+ *
41
+ * [baseYear] is the base year for the two-digit year.
42
+ * For example, if [baseYear] is 1960, then this format correctly works with years [1960..2059].
43
+ *
44
+ * On formatting, when given a year in the valid range, it returns the last two digits of the year,
45
+ * so 1993 becomes "93". When given a year outside the valid range, it returns the full year number
46
+ * with a leading sign, so 1850 becomes "+1850", and -200 becomes "-200".
47
+ *
48
+ * On parsing, it accepts either a two-digit year or a full year number with a leading sign.
49
+ * When given a two-digit year, it returns a year in the valid range, so "93" becomes 1993,
50
+ * and when given a full year number with a leading sign, it parses the full year number,
51
+ * so "+1850" becomes 1850.
52
+ */
53
+ public fun yearTwoDigits (baseYear : Int )
54
+
55
+ /* *
56
+ * A month-of-year number, from 1 to 12.
57
+ *
58
+ * By default, it's padded with zeros to two digits. This can be changed by passing [padding].
59
+ */
60
+ public fun monthNumber (padding : Padding = Padding .ZERO )
61
+
62
+ /* *
63
+ * A month name (for example, "January").
64
+ *
65
+ * Example:
66
+ * ```
67
+ * monthName(MonthNames.ENGLISH_FULL)
68
+ * ```
69
+ */
70
+ public fun monthName (names : MonthNames )
71
+
72
+ /* *
73
+ * A day-of-month number, from 1 to 31.
74
+ *
75
+ * By default, it's padded with zeros to two digits. This can be changed by passing [padding].
76
+ */
77
+ public fun dayOfMonth (padding : Padding = Padding .ZERO )
78
+
79
+ /* *
80
+ * A day-of-week name (for example, "Thursday").
81
+ *
82
+ * Example:
83
+ * ```
84
+ * dayOfWeek(DayOfWeekNames.ENGLISH_FULL)
85
+ * ```
86
+ */
87
+ public fun dayOfWeek (names : DayOfWeekNames )
88
+
89
+ /* *
90
+ * An existing [DateTimeFormat] for the date part.
91
+ *
92
+ * Example:
93
+ * ```
94
+ * date(LocalDate.Formats.ISO)
95
+ * ```
96
+ */
97
+ public fun date (format : DateTimeFormat <LocalDate >)
98
+ }
21
99
}
22
100
23
101
/* *
0 commit comments