mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:50:18 +00:00
8d4ead8e86
* add timezone support Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * update supermq Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * revert env variable Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * fix failing linter Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * address comments Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * revert env variable Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> * add reports title for context Signed-off-by: nyagamunene <stevenyaga2014@gmail.com> --------- Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
26 lines
543 B
Go
26 lines
543 B
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package reports
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// resolveTimezone returns a *time.Location from a user-provided IANA timezone name.
|
|
// Supported inputs:
|
|
// - IANA names (e.g., "Europe/Paris", "America/New_York").
|
|
// - Empty string defaults to UTC.
|
|
func resolveTimezone(s string) (*time.Location, error) {
|
|
s = strings.TrimSpace(s)
|
|
if s == "" {
|
|
return time.UTC, nil
|
|
}
|
|
loc, err := time.LoadLocation(s)
|
|
if err != nil {
|
|
return time.UTC, err
|
|
}
|
|
return loc, nil
|
|
}
|