forked from ajstarks/conditions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
almanac.go
86 lines (73 loc) · 2.28 KB
/
almanac.go
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
/*
* almanac.go
*
* This file is part of wu. It contains functions related to
* the -almanac switch (historical data).
*
* Written and maintained by Stephen Ramsay <sramsay.unl@gmail.com>
* and Anthony Starks.
*
* Last Modified: Wed Dec 18 16:10:51 CST 2013
*
* Copyright © 2010-2014 by Stephen Ramsay and Anthony Starks.
*
* wu is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* wu is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wu; see the file COPYING. If not see
* <http://www.gnu.org/licenses/>.
*/
package main
import (
"fmt"
)
type AlmanacConditions struct {
Almanac Almanac
}
type Almanac struct {
Temp_high Temp_high
Temp_low Temp_low
}
type Temp_high struct {
Normal Normal
Record Record
Recordyear string
}
type Temp_low struct {
Normal Normal
Record Record
Recordyear string
}
type Normal struct {
F string
C string
}
type Record struct {
F string
C string
}
// printAlmanac prints the Almanac for a given station to standard out
func PrintAlmanac(obs *AlmanacConditions, stationId string) {
normalHighF := obs.Almanac.Temp_high.Normal.F
normalHighC := obs.Almanac.Temp_high.Normal.C
normalLowF := obs.Almanac.Temp_low.Normal.F
normalLowC := obs.Almanac.Temp_low.Normal.C
recordHighF := obs.Almanac.Temp_high.Record.F
recordHighC := obs.Almanac.Temp_high.Record.C
recordHYear := obs.Almanac.Temp_high.Recordyear
recordLowF := obs.Almanac.Temp_low.Record.F
recordLowC := obs.Almanac.Temp_low.Record.C
recordLYear := obs.Almanac.Temp_low.Recordyear
fmt.Printf("Normal high: %s\u00B0 F (%s\u00B0 C)\n", normalHighF, normalHighC)
fmt.Printf("Record high: %s\u00B0 F (%s\u00B0 C) [%s]\n", recordHighF, recordHighC, recordHYear)
fmt.Printf("Normal low : %s\u00B0 F (%s\u00B0 C)\n", normalLowF, normalLowC)
fmt.Printf("Record low : %s\u00B0 F (%s\u00B0 C) [%s]\n", recordLowF, recordLowC, recordLYear)
}