Files
weatherapi/internal/adapters/inbound/httpapi/presenter/helpers.go
2026-03-20 09:44:53 -05:00

56 lines
855 B
Go

// helpers.go contains shared pointer and scalar conversion helpers.
// Layer: adapters/inbound/httpapi/presenter helper functions.
package presenter
import "time"
func celsiusToFahrenheitPtr(v *float64) *float64 {
if v == nil {
return nil
}
out := (*v * celsiusToFahrenheitScale) + celsiusToFahrenheitOffset
return &out
}
func scalePtr(v *float64, factor float64) *float64 {
if v == nil {
return nil
}
out := *v * factor
return &out
}
func copyFloat64Ptr(v *float64) *float64 {
if v == nil {
return nil
}
out := *v
return &out
}
func copyBoolPtr(v *bool) *bool {
if v == nil {
return nil
}
out := *v
return &out
}
func copyTimePtr(v *time.Time) *time.Time {
if v == nil {
return nil
}
out := *v
return &out
}
func boolText(v *bool) string {
if v == nil {
return ""
}
if *v {
return "true"
}
return "false"
}