timeutil

package
v9.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package timeutil provides shared time layouts and formatting/parsing helpers used across API handlers, exports, and reporting paths.

It centralizes ToughRADIUS date-time string conventions to keep serialized timestamps consistent across JSON, CSV, and UI-facing outputs.

Index

Constants

View Source
const (
	Datetime14Layout      = "20060102150405"
	Datetime8Layout       = "20060102"
	Datetime6Layout       = "200601"
	YYYYMMDDHHMMSS_LAYOUT = "2006-01-02 15:04:05"
	YYYYMMDDHHMM_LAYOUT   = "2006-01-02 15:04"
	YYYYMMDD_LAYOUT       = "2006-01-02"
)

Variables

View Source
var (
	ShangHaiLOC, _ = time.LoadLocation("Asia/Shanghai")
	EmptyTime, _   = time.Parse("2006-01-02 15:04:05 Z0700 MST", "1979-11-30 00:00:00 +0000 GMT")
)

Functions

func ComputeEndTime

func ComputeEndTime(times int, unit string) time.Time

func FmtDateString

func FmtDateString(t time.Time) string

FmtDateString formats t as "2006-01-02".

func FmtDatetime6String

func FmtDatetime6String(t time.Time) string

FmtDatetime6String formats t as "200601".

func FmtDatetime8String

func FmtDatetime8String(t time.Time) string

FmtDatetime8String formats t as "20060102".

func FmtDatetime14String

func FmtDatetime14String(t time.Time) string

FmtDatetime14String formats t as "20060102150405".

func FmtDatetimeMString

func FmtDatetimeMString(t time.Time) string

FmtDatetimeMString formats t as "2006-01-02 15:04".

func FmtDatetimeString

func FmtDatetimeString(t time.Time) string

FmtDatetimeString formats t as "2006-01-02 15:04:05".

func ParseTimeDesc

func ParseTimeDesc(timestr string) string

Types

type LocalTime

type LocalTime time.Time

func (LocalTime) MarshalCSV

func (t LocalTime) MarshalCSV() (string, error)

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) MarshalParam

func (t *LocalTime) MarshalParam() string

func (*LocalTime) UnmarshalJSON

func (t *LocalTime) UnmarshalJSON(data []byte) (err error)

func (*LocalTime) UnmarshalParam

func (t *LocalTime) UnmarshalParam(src string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL