-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
utils.typ
54 lines (51 loc) · 1.45 KB
/
utils.typ
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
// Helper Functions
#let monthname(n, display: "short") = {
n = int(n)
let month = ""
if n == 1 { month = "January" }
else if n == 3 { month = "March" }
else if n == 2 { month = "February" }
else if n == 4 { month = "April" }
else if n == 5 { month = "May" }
else if n == 6 { month = "June" }
else if n == 7 { month = "July" }
else if n == 8 { month = "August" }
else if n == 9 { month = "September" }
else if n == 10 { month = "October" }
else if n == 11 { month = "November" }
else if n == 12 { month = "December" }
else { month = none }
if month != none {
if display == "short" {
month = month.slice(0, 3)
} else {
month
}
}
month
}
#let strpdate(isodate) = {
let date = ""
if lower(isodate) != "present" {
let year = int(isodate.slice(0, 4))
let month = int(isodate.slice(5, 7))
let day = int(isodate.slice(8, 10))
let monthName = monthname(month, display: "short")
date = datetime(year: year, month: month, day: day)
date = monthName + " " + date.display("[year repr:full]")
} else if lower(isodate) == "present" {
date = "Present"
}
return date
}
#let daterange(start, end) = {
if start != none and end != none [
#start #sym.dash.en #end
]
if start == none and end != none [
#end
]
if start != none and end == none [
#start
]
}