-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradiation.go
47 lines (39 loc) · 1.14 KB
/
radiation.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
// SPDX-FileCopyrightText: 2023 Winni Neessen <wn@neessen.dev>
//
// SPDX-License-Identifier: MIT
package meteologix
import (
"fmt"
"math"
"time"
)
// Radiation is a type wrapper of an WeatherData for holding radiation values in WeatherData
type Radiation WeatherData
// IsAvailable returns true if an Radiation value was available at time of query
func (r Radiation) IsAvailable() bool {
return !r.notAvailable
}
// DateTime returns the time.Time object representing the date and time at which the Radiation
// value was queried
func (r Radiation) DateTime() time.Time {
return r.dateTime
}
// Value returns the float64 value of an Radiation
//
// If the Radiation is not available in the WeatherData, Value will return math.NaN instead.
func (r Radiation) Value() float64 {
if r.notAvailable {
return math.NaN()
}
return r.floatVal
}
// String satisfies the fmt.Stringer interface for the Radiation type
func (r Radiation) String() string {
return fmt.Sprintf("%.0fkJ/m²", r.floatVal)
}
// Source returns the Source of Pressure
//
// If the Source is not available it will return SourceUnknown
func (r Radiation) Source() Source {
return r.source
}