Skip to content

Commit cc6084b

Browse files
authored
New Calendar Identifiers (#1168)
Exposed identifiers for 12 new calendars
1 parent 683431a commit cc6084b

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

Sources/FoundationEssentials/Calendar/Calendar.swift

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,42 @@ public struct Calendar : Hashable, Equatable, Sendable {
6262
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
6363
case islamicUmmAlQura
6464

65+
@available(FoundationPreview 6.2, *)
66+
case bangla
67+
68+
@available(FoundationPreview 6.2, *)
69+
case gujarati
70+
71+
@available(FoundationPreview 6.2, *)
72+
case kannada
73+
74+
@available(FoundationPreview 6.2, *)
75+
case malayalam
76+
77+
@available(FoundationPreview 6.2, *)
78+
case marathi
79+
80+
@available(FoundationPreview 6.2, *)
81+
case odia
82+
83+
@available(FoundationPreview 6.2, *)
84+
case tamil
85+
86+
@available(FoundationPreview 6.2, *)
87+
case telugu
88+
89+
@available(FoundationPreview 6.2, *)
90+
case vikram
91+
92+
@available(FoundationPreview 6.2, *)
93+
case dangi
94+
95+
@available(FoundationPreview 6.2, *)
96+
case thai
97+
98+
@available(FoundationPreview 6.2, *)
99+
case vietnamese
100+
65101
package static let cldrKeywordKey = "ca"
66102
package static let legacyKeywordKey = ICULegacyKey("calendar")
67103

@@ -89,6 +125,18 @@ public struct Calendar : Hashable, Equatable, Sendable {
89125
case "roc": self = .republicOfChina
90126
case "islamic-tbla": self = .islamicTabular
91127
case "islamic-umalqura": self = .islamicUmmAlQura
128+
case "bangla": self = .bangla
129+
case "gujarati": self = .gujarati
130+
case "kannada": self = .kannada
131+
case "malayalam": self = .malayalam
132+
case "marathi": self = .marathi
133+
case "odia": self = .odia
134+
case "tamil": self = .tamil
135+
case "telugu": self = .telugu
136+
case "vikram": self = .vikram
137+
case "dangi": self = .dangi
138+
case "thai": self = .thai
139+
case "vietnamese": self = .vietnamese
92140
default: return nil
93141
}
94142
}
@@ -111,6 +159,18 @@ public struct Calendar : Hashable, Equatable, Sendable {
111159
case .republicOfChina: return "roc"
112160
case .islamicTabular: return "islamic-tbla"
113161
case .islamicUmmAlQura: return "islamic-umalqura"
162+
case .bangla: return "bangla"
163+
case .gujarati: return "gujarati"
164+
case .kannada: return "kannada"
165+
case .malayalam: return "malayalam"
166+
case .marathi: return "marathi"
167+
case .odia: return "odia"
168+
case .tamil: return "tamil"
169+
case .telugu: return "telugu"
170+
case .vikram: return "vikram"
171+
case .dangi: return "dangi"
172+
case .thai: return "thai"
173+
case .vietnamese: return "vietnamese"
114174
}
115175
}
116176

@@ -133,6 +193,18 @@ public struct Calendar : Hashable, Equatable, Sendable {
133193
case .coptic: return "coptic"
134194
case .ethiopicAmeteMihret: return "ethiopic"
135195
case .ethiopicAmeteAlem: return "ethiopic-amete-alem"
196+
case .bangla: return "bangla"
197+
case .gujarati: return "gujarati"
198+
case .kannada: return "kannada"
199+
case .malayalam: return "malayalam"
200+
case .marathi: return "marathi"
201+
case .odia: return "odia"
202+
case .tamil: return "tamil"
203+
case .telugu: return "telugu"
204+
case .vikram: return "vikram"
205+
case .dangi: return "dangi"
206+
case .thai: return "thai"
207+
case .vietnamese: return "vietnamese"
136208
}
137209
}
138210

@@ -1312,6 +1384,30 @@ public struct Calendar : Hashable, Equatable, Sendable {
13121384
return .islamicTabular
13131385
case .islamicUmmAlQura:
13141386
return .islamicUmmAlQura
1387+
case .bangla:
1388+
return .bangla
1389+
case .gujarati:
1390+
return .gujarati
1391+
case .kannada:
1392+
return .kannada
1393+
case .malayalam:
1394+
return .malayalam
1395+
case .marathi:
1396+
return .marathi
1397+
case .odia:
1398+
return .odia
1399+
case .tamil:
1400+
return .tamil
1401+
case .telugu:
1402+
return .telugu
1403+
case .vikram:
1404+
return .vikram
1405+
case .dangi:
1406+
return .dangi
1407+
case .thai:
1408+
return .thai
1409+
case .vietnamese:
1410+
return .vietnamese
13151411
}
13161412
}
13171413

@@ -1349,6 +1445,30 @@ public struct Calendar : Hashable, Equatable, Sendable {
13491445
return .islamicTabular
13501446
case .islamicUmmAlQura:
13511447
return .islamicUmmAlQura
1448+
case .bangla:
1449+
return .bangla
1450+
case .gujarati:
1451+
return .gujarati
1452+
case .kannada:
1453+
return .kannada
1454+
case .malayalam:
1455+
return .malayalam
1456+
case .marathi:
1457+
return .marathi
1458+
case .odia:
1459+
return .odia
1460+
case .tamil:
1461+
return .tamil
1462+
case .telugu:
1463+
return .telugu
1464+
case .vikram:
1465+
return .vikram
1466+
case .dangi:
1467+
return .dangi
1468+
case .thai:
1469+
return .thai
1470+
case .vietnamese:
1471+
return .vietnamese
13521472
default:
13531473
return nil
13541474
}

Sources/FoundationInternationalization/Calendar/Calendar_ICU.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,33 @@ internal final class _CalendarICU: _CalendarProtocol, @unchecked Sendable {
14461446
if time < -42790982400.0 { return nil }
14471447
case .chinese:
14481448
if time < -146325744000.0 { return nil }
1449+
case .bangla:
1450+
fallthrough
1451+
case .gujarati:
1452+
fallthrough
1453+
case .kannada:
1454+
fallthrough
1455+
case .malayalam:
1456+
fallthrough
1457+
case .marathi:
1458+
fallthrough
1459+
case .odia:
1460+
fallthrough
1461+
case .tamil:
1462+
fallthrough
1463+
case .telugu:
1464+
fallthrough
1465+
case .vikram:
1466+
// TODO: This is copied from `.indian` and needs to be revisited for each new calendar.
1467+
if time < -60645542400.0 { return nil }
1468+
return Date(timeIntervalSinceReferenceDate: -60645542400.0)
1469+
case .dangi:
1470+
fallthrough
1471+
case .thai:
1472+
fallthrough
1473+
case .vietnamese:
1474+
// TODO: This is copied from `.chinese` and needs to be revisited for each new calendar.
1475+
if time < -146325744000.0 { return nil }
14491476
}
14501477
case .hour:
14511478
let ti = Double(timeZone.secondsFromGMT(for: capped))
@@ -1541,6 +1568,33 @@ internal final class _CalendarICU: _CalendarProtocol, @unchecked Sendable {
15411568
if time < -42790982400.0 { return nil }
15421569
case .chinese:
15431570
if time < -146325744000.0 { return nil }
1571+
case .bangla:
1572+
fallthrough
1573+
case .gujarati:
1574+
fallthrough
1575+
case .kannada:
1576+
fallthrough
1577+
case .malayalam:
1578+
fallthrough
1579+
case .marathi:
1580+
fallthrough
1581+
case .odia:
1582+
fallthrough
1583+
case .tamil:
1584+
fallthrough
1585+
case .telugu:
1586+
fallthrough
1587+
case .vikram:
1588+
// TODO: This is copied from `.indian` and needs to be revisited for each new calendar.
1589+
if time < -60645542400.0 { return nil }
1590+
return DateInterval(start: Date(timeIntervalSinceReferenceDate: -60645542400.0), duration: inf_ti)
1591+
case .dangi:
1592+
fallthrough
1593+
case .thai:
1594+
fallthrough
1595+
case .vietnamese:
1596+
// TODO: This is copied from `.chinese` and needs to be revisited for each new calendar.
1597+
if time < -146325744000.0 { return nil }
15441598
}
15451599
case .hour:
15461600
let ti = Double(timeZone.secondsFromGMT(for: capped))

0 commit comments

Comments
 (0)