forked from jskherman/imprecv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.typ
51 lines (48 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
// 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 { result = none }
if month != none {
if display == "short" {
month = month.slice(0, 3)
} else {
month
}
}
month
}
#let strpdate(isodate) = {
let date = ""
if lower(isodate) != "present" {
date = datetime(
year: int(isodate.slice(0, 4)),
month: int(isodate.slice(5, 7)),
day: 1 // IGNORE day
)
date = date.display("[month repr:short]") + " " + date.display("[year repr:full]")
} else if lower(isodate) == "present" {
date = "Present"
}
return date
}
// Get in inner reference label for two varialbles mapped to "prefix-postfix" using the first word in the strings provided.
#let ref-label(pre, post) = {
let l = lower(pre.split(" ").at(0))
if post == "" {
return label(l)
}
label(l + "-" + lower(post.split(" ").at(0)))
}