-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ask-Ajpula.ps1
685 lines (574 loc) · 22.2 KB
/
Ask-Ajpula.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Procudes Maya calendar date information from a given Gregorian date.
.DESCRIPTION
Produce a long count date in the classic notation from given date string.
The output format can be controlled by the Mode parameter.
Plain:
Standard scientific notation, e.g. 10.9.15.15.9 4 Muluk 2 Yaxk'in
Json:
All information will be written in Json format.
It always includes everthing regardless of the switches Tzolkin, Haab,
CalendarRound and NoLongCount.
Latex:
Long count, Tzolk'in and Haab information will be written in a Latex readable format.
.INPUTS
None. You cannot pipe objects into this script.
.OUTPUTS
Long count date, Haab date and/or Tzolk'in date in either plain text, Json or Latex format.
.EXAMPLE
./Ask-Ajpula.ps1 -GregorianDate 2022-12-30 -CalendarRound
13.0.10.2.18 9 Etz'nab' 11 K'ank'in
.EXAMPLE
./Ask-Ajpula.ps1 -GregorianDate 2023-04-03 -CalendarRound -PreferMonthEnding
13.0.10.7.12 12 Eb' Ending of Wayeb
.LINK
https://github.com/yax-lakam-tuun/maya-decipherment
#>
[CmdletBinding()]
param (
[ValidatePattern("\d{4}-\d{2}-\d{2}")]
[string]
# Gregorian date in ISO format. Current date is used when parameter is omitted.
$GregorianDate = $(Get-Date -Format "yyyy-MM-dd"),
[Parameter(ParameterSetName="PlainSet")]
[switch]
# Include Tzolk'in and Haab date in plain mode
$CalendarRound,
[Parameter(ParameterSetName="PlainSet")]
[switch]
# Exclude Long Count date in plain mode
$NoLongCount,
[Parameter(ParameterSetName="PlainSet")]
[switch]
# Include Tzolk'in date in plain mode
$Tzolkin,
[Parameter(ParameterSetName="PlainSet")]
[switch]
# Include Haab date in plain mode
$Haab,
[Parameter(ParameterSetName="PlainSet")]
[Parameter(ParameterSetName="JsonSet")]
[switch]
# The transition between two months is written as "Ending" instead of "Seating"
$PreferMonthEnding,
[Parameter(ParameterSetName="PlainSet")]
[switch]
# Use plain mode
$Plain,
[Parameter(ParameterSetName="JsonSet")]
[switch]
# Use json mode
$Json = $false,
[Parameter(ParameterSetName="LatexSet")]
[switch]
# Use json mode
$Latex = $false
)
function Get-Remainder() {
[CmdletBinding()]
param (
[int] $Number,
[int] $Divisor
)
return (($Number % $Divisor) + $Divisor) % $Divisor
}
class DistanceNumber {
[int] $Days = 0
DistanceNumber([int] $Days) {
$this.Days = $Days
}
}
class MayaNumber {
[int] $Days = 0
MayaNumber([int] $Days) {
$this.Days = $Days
}
}
class LongCountDate {
[int[]] $Digits
LongCountDate([int[]] $Digits) {
if ($Digits.Length -lt 5) {
throw "A Long Count date consists of at least 5 digits"
}
if ($Digits[1] -lt 0 -or $Digits[1] -gt 17) {
throw "A Long Count Winal digit may range from 0 to 17 only"
}
foreach($Digit in $Digits) {
if ($Digit -lt 0 -or $Digit -gt 19) {
throw "A Long Count digit may range from 0 to 19 only"
}
}
$this.Digits = $Digits
}
LongCountDate([MayaNumber] $MayaNumber) {
$Days = $MayaNumber.Days
$CurrentWeight = 1
$NextWeight = 20
$Result = @()
while($Days -ne 0) {
$LowerPart = Get-Remainder -Number $Days -Divisor $NextWeight
$Result += $LowerPart / $CurrentWeight
$Days = $Days - $LowerPart
$CurrentWeight = $NextWeight
$NextWeight = ($NextWeight -eq 20) ? 360 : 20 * $NextWeight
}
if ($Result.Length -lt 5) {
$Result += (0..(5 - $Result.Length - 1)) | ForEach-Object 0
}
$this.Digits = $Result
}
[string] StandardNotation() {
$StringDigits = $this.Digits -as [string[]]
[array]::Reverse($StringDigits)
return $StringDigits -join "."
}
[MayaNumber] MayaNumber() {
$Weight = 1
$Sum = 0
foreach($Digit in $this.Digits) {
$Sum += $Digit * $Weight
$Weight = ($Weight -eq 20) ? 360 : 20 * $Weight
}
return [MayaNumber]::new($Sum)
}
}
enum TzolkinDayName {
Imix
Ik
Akbal
Kan
Chicchan
Kimi
Manik
Lamat
Muluk
Ok
Chuwen
Eb
Ben
Ix
Men
Kib
Kaban
Etznab
Kawak
Ajaw
}
function Get-TzolkinDayStandardName() {
[CmdletBinding()]
param (
[TzolkinDayName] $DayName
)
$StandardNames = (
"Imix", "Ik'", "Ak'b'al", "K'an",
"Chicchan", "Kimi", "Manik'", "Lamat",
"Muluk", "Ok", "Chuwen", "Eb'",
"B'en", "Ix", "Men", "Kib'",
"Kab'an", "Etz'nab'", "Kawak", "Ajaw"
)
return $StandardNames[$DayName]
}
class TzolkinDate {
static [int] $DayCount = 260
static [int] $DayNameCount = 20
static [int] $TrecenaDayCount = 13
static [int] $TrecenaDayMin = 1
static [int] $TrecenaDayMax = 13
[ValidateRange(0, 259)]
[int] $Index = 0
TzolkinDate([int] $TrecenaDay, [TzolkinDayName] $DayName) {
if ($TrecenaDay -lt $this::TrecenaDayMin -or $TrecenaDay -gt $this::TrecenaDayMax) {
throw "A trecena has only days from 1 to 13 "
}
$X = $DayName * (-3) * $this::TrecenaDayCount +
($TrecenaDay - $this::TrecenaDayMin) * 2 * $this::DayNameCount
$this.Index = $(Get-Remainder -Number $X -Divisor $this::DayCount)
}
TzolkinDate([int] $Index) {
$this.Index = $Index
}
[int] TrecenaDay() {
$Day0 = Get-Remainder -Number $this.Index -Divisor $this::TrecenaDayCount
return $this::TrecenaDayMin + $Day0
}
[TzolkinDayName] DayName() {
return Get-Remainder -Number $this.Index -Divisor $this::DayNameCount
}
[string] StandardNotation() {
$TrecendaDayString = $this.TrecenaDay() -as [string]
$DayNameString = Get-TzolkinDayStandardName -DayName $this.DayName()
return $TrecendaDayString + " " + $DayNameString
}
[int] Ordinal() {
return 1 + $this.Index
}
[TzolkinDate] AddDays([DistanceNumber] $Distance) {
$NewIndex = Get-Remainder -Number ($this.Index + $Distance.Days) -Divisor $this::DayCount
return $this::new($NewIndex)
}
}
enum HaabMonth {
Pop
Wo
Sip
Sotz
Sek
Xul
Yaxkin
Mol
Chen
Yax
Sak
Keh
Mak
Kankin
Muwan
Pax
Kayab
Kumku
Wayeb
}
function Get-HaabMonthStandardName()
{
[CmdletBinding()]
param (
[HaabMonth] $Month
)
$Months = (
"Pop", "Wo'", "Sip", "Sotz'", "Sek", "Xul", "Yaxk'in", "Mol", "Ch'en",
"Yax", "Sak'", "Keh", "Mak", "K'ank'in", "Muwan", "Pax", "K'ayab'", "Kumk'u", "Wayeb"
)
return $Months[$Month]
}
class HaabDate {
static [int] $DayCount = 365
static [int] $WinalCount = 19
static [int] $WinalDayCount = 20
static [int] $WayebDayCount = 5
[ValidateRange(0,364)][int] $Index = 0
HaabDate([int] $Day, [HaabMonth] $Month) {
if ($Month -eq [HaabMonth]::Wayeb -and $Day -gt $this::WayebDayCount) {
throw "Wayeb month has only days from 1 to 5"
}
if ($Day -gt $this::WinalDayCount) {
throw "A regular month has only days from 1 to 20"
}
$this.Index = $this::WinalDayCount * $Month + ($Day - 1)
}
HaabDate([int] $Index) {
$this.Index = $Index
}
[int] Day() {
return 1 + $(Get-Remainder -Number $this.Index -Divisor $this::WinalDayCount)
}
[HaabMonth] Month() {
return [Math]::Floor($this.Index / $this::WinalDayCount) -as [HaabMonth]
}
[string] StandardNotation([bool] $PreferMonthEnding) {
$D = $this.Day()
$M = $this.Month()
$MaxDays = $M -eq [HaabMonth]::Wayeb ? $this::WayebDayCount : $this::WinalDayCount
if ($D -eq $MaxDays) {
if ($PreferMonthEnding -eq $true) {
return "Ending of " + $(Get-HaabMonthStandardName -Month $M)
} else {
$M = Get-Remainder -Number ($M + 1) -Divisor $this::WinalCount
return "Seating of " + $(Get-HaabMonthStandardName -Month $M)
}
} else {
$DayString = $D -as [string]
$MonthString = Get-HaabMonthStandardName -Month $M
return $DayString + " " + $MonthString
}
}
[int] Ordinal() {
return 1 + $this.Index
}
[HaabDate] AddDays([DistanceNumber] $Distance) {
$NewIndex = Get-Remainder -Number ($this.Index + $Distance.Days) -Divisor $this::DayCount
return $this::new($NewIndex)
}
}
function Get-TzolkinDateFrom {
[CmdletBinding()]
param (
[MayaNumber] $MayaNumber
)
$BaseDate = [TzolkinDate]::new(4, [TzolkinDayName]::Ajaw)
return $BaseDate.AddDays($MayaNumber.Days)
}
function Get-HaabDateFrom {
[CmdletBinding()]
param (
[MayaNumber] $MayaNumber
)
$BaseDate = [HaabDate]::new(8, [HaabMonth]::Kumku)
return $BaseDate.AddDays($MayaNumber.Days)
}
class MartinSkidmoreCorrelation {
static [MayaNumber] MayaNumberFrom([DateTime] $Date) {
# julian date 16 July 790
$PocoUinicDate = [DateTime]::ParseExact("0790-07-20", "yyyy-MM-dd", $null)
$PocoUinicMayaNumber = [LongCountDate]::new((16, 13, 19, 17, 9)).MayaNumber()
$Delta = New-TimeSpan –Start $PocoUinicDate –End $Date
return [MayaNumber]::new($PocoUinicMayaNumber.Days + $Delta.Days)
}
}
function Write-Plain {
[CmdletBinding()]
param (
[MayaDate] $MayaDate,
[bool] $LongCount = $true,
[bool] $Tzolkin = $false,
[bool] $Haab = $false,
[bool] $PreferMonthEnding = $false
)
$Output = @()
if ($LongCount) {
$Output += $MayaDate.LongCountDate.StandardNotation()
}
if ($Tzolkin) {
$Output += $MayaDate.TzolkinDate.StandardNotation()
}
if ($Haab) {
$Output += $MayaDate.HaabDate.StandardNotation($PreferMonthEnding)
}
Write-Output $($Output -join ' ')
}
function Write-Json {
[CmdletBinding()]
param (
[DateTime] $GregorianDate,
[MayaDate] $MayaDate,
[bool] $PreferMonthEnding
)
$LongCount = [ordered]@{
standardNotation = $MayaDate.LongCountDate.StandardNotation()
digits = $MayaDate.LongCountDate.Digits
}
$Tzolkin = [ordered]@{
standardNotation = $MayaDate.TzolkinDate.StandardNotation()
trecenaDay = $MayaDate.TzolkinDate.TrecenaDay()
dayName = Get-TzolkinDayStandardName -DayName $MayaDate.TzolkinDate.DayName()
dayNameOrdinal = $MayaDate.TzolkinDate.DayName() -as [int]
ordinal = $MayaDate.TzolkinDate.Ordinal()
}
$Haab = [ordered]@{
standardNotation = $MayaDate.HaabDate.StandardNotation($PreferMonthEnding)
day = $MayaDate.HaabDate.Day()
monthName = $(Get-HaabMonthStandardName -Month $MayaDate.HaabDate.Month())
month = $MayaDate.HaabDate.Month() -as [int]
ordinal = $MayaDate.HaabDate.Ordinal()
}
$GregorianDate = $(Get-Date $date -Format "yyyy-MM-dd")
$All = [ordered]@{
gregorianDate = $GregorianDate
longCountDate = $LongCount
tzolkin = $Tzolkin
haab = $Haab
}
Write-Output $($All | ConvertTo-Json)
}
function Write-Latex {
[CmdletBinding()]
param (
[DateTime] $GregorianDate,
[MayaDate] $MayaDate,
[bool] $PreferMonthEnding,
[string] $Prefix
)
$LatexGregorianDate = $(Get-Date $date -Format "yyyy--MM--dd")
$LongCount = $MayaDate.LongCountDate.StandardNotation()
$Tzolkin = $MayaDate.TzolkinDate.StandardNotation()
$Haab = $MayaDate.HaabDate.StandardNotation($PreferMonthEnding)
$Lines = @(
"\newcommand{\$($Prefix)gregoriandate}{$LatexGregorianDate\xspace}",
"\newcommand{\$($Prefix)longcount}{$LongCount\xspace}",
"\newcommand{\$($Prefix)tzolkin}{$Tzolkin\xspace}",
"\newcommand{\$($Prefix)haab}{$Haab\xspace}"
)
Write-Output ($Lines -join "`n")
}
class MayaDate {
[MayaNumber] $MayaNumber
[LongCountDate] $LongCountDate
[TzolkinDate] $TzolkinDate
[HaabDate] $HaabDate
MayaDate([MayaNumber] $MayaNumber) {
$this.MayaNumber = $MayaNumber
$this.LongCountDate = [LongCountDate]::new($MayaNumber)
$this.TzolkinDate = Get-TzolkinDateFrom -MayaNumber $MayaNumber
$this.HaabDate = Get-HaabDateFrom -MayaNumber $MayaNumber
}
}
function Main {
[CmdletBinding()]
param (
[string] $GregorianDate,
[switch] $CalendarRound,
[switch] $NoLongCount,
[switch] $Tzolkin,
[switch] $Haab,
[switch] $PreferMonthEnding,
[switch] $Plain,
[switch] $Json = $false,
[switch] $Latex = $false
)
$Date = [DateTime]::ParseExact($GregorianDate, "yyyy-MM-dd", $null)
$MayaNumber = [MartinSkidmoreCorrelation]::MayaNumberFrom($Date)
$MayaDate = [MayaDate]::new($MayaNumber)
if (!$Plain -and !$Json -and !$Latex) {
$Plain = $true
}
if ($Plain) {
$Parameters = @{
MayaDate = $MayaDate
LongCount = $NoLongCount ? $false : $true
Tzolkin = $Tzolkin -or $CalendarRound
Haab = $Haab -or $CalendarRound
PreferMonthEnding = $PreferMonthEnding
}
Write-Plain @Parameters
}
if ($Json) {
$Parameters = @{
GregorianDate = $Date
MayaDate = $MayaDate
PreferMonthEnding = $PreferMonthEnding
}
Write-Json @Parameters
}
if ($Latex) {
$Parameters = @{
GregorianDate = $Date
MayaDate = $MayaDate
PreferMonthEnding = $PreferMonthEnding
Prefix = "documentversion"
}
Write-Latex @Parameters
}
}
function Assert {
[CmdletBinding()]
param (
[string] $Statement,
$Expected
)
$Actual = $($Statement)
if ($Actual -eq $($Expected)) {
return
}
Write-Warning "Test failed."
Write-Warning "Actual: $Actual"
Write-Warning "Expected: $Expected"
Write-Error "Test failed"
Exit 1
}
function Test-LongCountDate {
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(0)).StandardNotation()) -Expected "0.0.0.0.0"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(1)).StandardNotation()) -Expected "0.0.0.0.1"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(19)).StandardNotation()) -Expected "0.0.0.0.19"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(20)).StandardNotation()) -Expected "0.0.0.1.0"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(359)).StandardNotation()) -Expected "0.0.0.17.19"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(360)).StandardNotation()) -Expected "0.0.1.0.0"
Assert -Statement ([LongCountDate]::new([MayaNumber]::new(1425516)).StandardNotation()) -Expected "9.17.19.13.16"
}
function Test-TzolkinDate {
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Imix).Ordinal()) -Expected 1
Assert -Statement ([TzolkinDate]::new(2, [TzolkinDayName]::Ik).Ordinal()) -Expected 2
Assert -Statement ([TzolkinDate]::new(3, [TzolkinDayName]::Akbal).Ordinal()) -Expected 3
Assert -Statement ([TzolkinDate]::new(7, [TzolkinDayName]::Chicchan).Ordinal()) -Expected 85
Assert -Statement ([TzolkinDate]::new(13, [TzolkinDayName]::Ajaw).Ordinal()) -Expected 260
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Imix).TrecenaDay()) -Expected 1
Assert -Statement ([TzolkinDate]::new(3, [TzolkinDayName]::Ben).TrecenaDay()) -Expected 3
Assert -Statement ([TzolkinDate]::new(8, [TzolkinDayName]::Kawak).TrecenaDay()) -Expected 8
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Imix).DayName()) -Expected ([TzolkinDayName]::Imix)
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Ben).DayName()) -Expected ([TzolkinDayName]::Ben)
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Kawak).DayName()) -Expected ([TzolkinDayName]::Kawak)
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Imix).StandardNotation()) -Expected "1 Imix"
Assert -Statement ([TzolkinDate]::new(2, [TzolkinDayName]::Ik).StandardNotation()) -Expected "2 Ik'"
Assert -Statement ([TzolkinDate]::new(3, [TzolkinDayName]::Akbal).StandardNotation()) -Expected "3 Ak'b'al"
Assert -Statement ([TzolkinDate]::new(7, [TzolkinDayName]::Chicchan).StandardNotation()) -Expected "7 Chicchan"
Assert -Statement ([TzolkinDate]::new(13, [TzolkinDayName]::Ajaw).StandardNotation()) -Expected "13 Ajaw"
Assert -Statement ([TzolkinDate]::new(1, [TzolkinDayName]::Imix).AddDays(1).StandardNotation()) -Expected "2 Ik'"
Assert -Statement ([TzolkinDate]::new(2, [TzolkinDayName]::Ik).AddDays(5).StandardNotation()) -Expected "7 Manik'"
Assert -Statement ([TzolkinDate]::new(3, [TzolkinDayName]::Akbal).AddDays(13).StandardNotation()) -Expected "3 Kib'"
Assert -Statement ([TzolkinDate]::new(11, [TzolkinDayName]::Akbal).AddDays(20).StandardNotation()) -Expected "5 Ak'b'al"
Assert -Statement ([TzolkinDate]::new(11, [TzolkinDayName]::Akbal).AddDays(-1).StandardNotation()) -Expected "10 Ik'"
Assert -Statement ([TzolkinDate]::new(11, [TzolkinDayName]::Akbal).AddDays(-260).StandardNotation()) -Expected "11 Ak'b'al"
Assert -Statement ([TzolkinDate]::new(0).StandardNotation()) -Expected "1 Imix"
Assert -Statement ([TzolkinDate]::new(1).StandardNotation()) -Expected "2 Ik'"
Assert -Statement ([TzolkinDate]::new(2).StandardNotation()) -Expected "3 Ak'b'al"
Assert -Statement ([TzolkinDate]::new(259).StandardNotation()) -Expected "13 Ajaw"
}
function Test-HaabDate {
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Pop).Ordinal()) -Expected 1
Assert -Statement ([HaabDate]::new(20, [HaabMonth]::Pop).Ordinal()) -Expected 20
Assert -Statement ([HaabDate]::new(5, [HaabMonth]::Wayeb).Ordinal()) -Expected 365
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Pop).Day()) -Expected 1
Assert -Statement ([HaabDate]::new(2, [HaabMonth]::Pop).Day()) -Expected 2
Assert -Statement ([HaabDate]::new(15, [HaabMonth]::Pop).Day()) -Expected 15
Assert -Statement ([HaabDate]::new(15, [HaabMonth]::Kayab).Day()) -Expected 15
Assert -Statement ([HaabDate]::new(17, [HaabMonth]::Muwan).Day()) -Expected 17
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Pop).Month()) -Expected ([HaabMonth]::Pop)
Assert -Statement ([HaabDate]::new(2, [HaabMonth]::Wo).Month()) -Expected ([HaabMonth]::Wo)
Assert -Statement ([HaabDate]::new(3, [HaabMonth]::Wayeb).Month()) -Expected ([HaabMonth]::Wayeb)
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Pop).StandardNotation($true)) -Expected "1 Pop"
Assert -Statement ([HaabDate]::new(5, [HaabMonth]::Yax).StandardNotation($true)) -Expected "5 Yax"
Assert -Statement ([HaabDate]::new(10, [HaabMonth]::Chen).StandardNotation($true)) -Expected "10 Ch'en"
Assert -Statement ([HaabDate]::new(20, [HaabMonth]::Kankin).StandardNotation($true)) -Expected "Ending of K'ank'in"
Assert -Statement ([HaabDate]::new(20, [HaabMonth]::Kankin).StandardNotation($false)) -Expected "Seating of Muwan"
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Pop).AddDays(10).StandardNotation($true)) -Expected "11 Pop"
Assert -Statement ([HaabDate]::new(13, [HaabMonth]::Pop).AddDays(10).StandardNotation($true)) -Expected "3 Wo'"
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Wayeb).AddDays(4).StandardNotation($true)) -Expected "Ending of Wayeb"
Assert -Statement ([HaabDate]::new(1, [HaabMonth]::Wayeb).AddDays(5).StandardNotation($true)) -Expected "1 Pop"
Assert -Statement ([HaabDate]::new(10, [HaabMonth]::Muwan).AddDays(1000).StandardNotation($true)) -Expected "15 Yax"
Assert -Statement ([HaabDate]::new(5, [HaabMonth]::Muwan).AddDays(-10).StandardNotation($true)) -Expected "15 K'ank'in"
Assert -Statement ([HaabDate]::new(0).StandardNotation($true)) -Expected "1 Pop"
Assert -Statement ([HaabDate]::new(10).StandardNotation($true)) -Expected "11 Pop"
Assert -Statement ([HaabDate]::new(300).StandardNotation($true)) -Expected "1 Pax"
}
function Test-Plain {
Assert -Statement (Main -Plain -GregorianDate 0790-07-20) -Expected "9.17.19.13.16"
Assert -Statement (Main -Plain -GregorianDate 2022-12-30) -Expected "13.0.10.2.18"
Assert -Statement (Main -Plain -CalendarRound -GregorianDate 2022-12-30) -Expected "13.0.10.2.18 9 Etz'nab' 11 K'ank'in"
Assert -Statement (Main -Plain -CalendarRound -GregorianDate 2023-01-08) -Expected "13.0.10.3.7 5 Manik' Seating of Muwan"
Assert -Statement (Main -Plain -CalendarRound -GregorianDate 2023-01-08 -PreferMonthEnding) -Expected "13.0.10.3.7 5 Manik' Ending of K'ank'in"
Assert -Statement (Main -Plain -CalendarRound -GregorianDate 2023-04-03) -Expected "13.0.10.7.12 12 Eb' Seating of Pop"
Assert -Statement (Main -Plain -CalendarRound -GregorianDate 2023-04-03 -PreferMonthEnding) -Expected "13.0.10.7.12 12 Eb' Ending of Wayeb"
Assert -Statement (Main -Plain -NoLongCount -CalendarRound -GregorianDate 2022-12-30) -Expected "9 Etz'nab' 11 K'ank'in"
Assert -Statement (Main -Plain -Tzolkin -GregorianDate 2022-12-30) -Expected "13.0.10.2.18 9 Etz'nab'"
Assert -Statement (Main -Plain -NoLongCount -Tzolkin 2022-12-30) -Expected "9 Etz'nab'"
Assert -Statement (Main -Plain -Haab -GregorianDate 2022-12-30) -Expected "13.0.10.2.18 11 K'ank'in"
Assert -Statement (Main -Plain -NoLongCount -Haab -GregorianDate 2022-12-30) -Expected "11 K'ank'in"
}
function Test-Latex {
$Nominal =
"\newcommand{\documentversiongregoriandate}{2023--01--10\xspace}
\newcommand{\documentversionlongcount}{13.0.10.3.9\xspace}
\newcommand{\documentversiontzolkin}{7 Muluk\xspace}
\newcommand{\documentversionhaab}{2 Muwan\xspace}"
Assert -Statement (Main -Latex -GregorianDate 2023-01-10) -Expected $Nominal
}
function Test-Script {
Test-LongCountDate
Test-TzolkinDate
Test-HaabDate
Test-Plain
Test-Latex
}
Test-Script
$MainParameter = @{
GregorianDate = $GregorianDate
CalendarRound = $CalendarRound
NoLongCount = $NoLongCount
Tzolkin = $Tzolkin
Haab = $Haab
PreferMonthEnding = $PreferMonthEnding
Plain = $Plain
Json = $Json
Latex = $Latex
}
Main @MainParameter