Winni Neessen
e3756a5466
The comment for the DateTime function in radiation.go was updated to more accurately describe its functionality. The previous version of the comment suggested that the function returns a boolean value indicating the availability of a radiation value at the time of a query. However, the function actually returns a time.Time object representing the date and time of the query. The comment was thus updated to reflect this.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
// 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.na
|
|
}
|
|
|
|
// 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.dt
|
|
}
|
|
|
|
// Value returns the float64 value of an Radiation
|
|
// If the Radiation is not available in the WeatherData
|
|
// Vaule will return math.NaN instead.
|
|
func (r Radiation) Value() float64 {
|
|
if r.na {
|
|
return math.NaN()
|
|
}
|
|
return r.fv
|
|
}
|
|
|
|
// String satisfies the fmt.Stringer interface for the Radiation type
|
|
func (r Radiation) String() string {
|
|
return fmt.Sprintf("%.0fkJ/m²", r.fv)
|
|
}
|
|
|
|
// Source returns the Source of Pressure
|
|
// If the Source is not available it will return SourceUnknown
|
|
func (r Radiation) Source() Source {
|
|
return r.s
|
|
}
|