-
Notifications
You must be signed in to change notification settings - Fork 18
/
get-EasterDate.pq
83 lines (83 loc) · 2.57 KB
/
get-EasterDate.pq
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
let
outputEster =
(EasterYear as number) as date =>
let
FirstDig = Number.RoundDown(EasterYear / 100),
Remain19 = Number.Mod(EasterYear, 19),
Temp1 =
Number.Mod(
Number.RoundDown((FirstDig - 15) / 2)
+ 202
- 11
* Remain19,
30
),
tA =
Temp1
+ 21
+ (
if
(Temp1 = 29)
or ((Temp1 = 28) and (Remain19 > 10))
then
-1
else
0
),
tB = Number.Mod(tA - 19, 7),
tCpre = Number.Mod(40 - FirstDig, 4),
tC =
tCpre
+ (
if tCpre = 3 then
1
else
0
)
+ (
if tCpre > 1 then
1
else
0
),
Temp2 = Number.Mod(EasterYear, 100),
tD =
Number.Mod(
Temp2 + Number.RoundDown(Temp2 / 4),
7
),
tE = Number.Mod(20 - tB - tC - tD, 7) + 1,
d = tA + tE,
EasterDay =
if d > 31 then
d - 31
else
d,
EasterMonth =
if d > 31 then
4
else
3,
Result =
#date(
EasterYear,
EasterMonth,
EasterDay
)
in
Result,
documentation = [
Documentation.Name = " get-EasterDate.pq ",
Documentation.Description = " Returning Date of Easter Sunday for inputed Year. ",
Documentation.Source = "https://www.jaknapowerbi.cz . ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Štěpán Rešl "
]
in
Value.ReplaceType(
outputEster,
Value.ReplaceMetadata(
Value.Type(outputEster),
documentation
)
)