-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathholiday.go
More file actions
45 lines (38 loc) · 795 Bytes
/
holiday.go
File metadata and controls
45 lines (38 loc) · 795 Bytes
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
//contains all functions and structs related to storing and retreiving holiday infos
package main
import (
"fmt"
"time"
)
type holiday struct {
Name string
HolidayDate time.Time `db:"holiday_date"`
Val float64
}
func getHolidaysInRange(from, to time.Time) ([]holiday, error) {
Info.Printf("getHolidaysInRange(%v,%v)\n", from.Format(jsDateTime), to.Format(jsDateTime))
var ret []holiday
rows, err := db.Queryx(`
select
name,
holiday_date,
val
from
holidays
where
holiday_date between $1 and $2`,
from, to)
if err != nil {
fmt.Println(err)
return []holiday{}, err
}
defer rows.Close()
for rows.Next() {
var h holiday
err = rows.StructScan(&h)
if err == nil {
ret = append(ret, h)
}
}
return ret, nil
}