util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountSI

func ByteCountSI(b int64) string

func DefaultWorkDir

func DefaultWorkDir(account string) string

DefaultWorkDir returns the default work directory path for decrypted output. Each account gets its own subdirectory under ./data/.

func GetDirSize

func GetDirSize(dir string) string

func IsNumeric

func IsNumeric(s string) bool

func PerfectTimeFormat

func PerfectTimeFormat(start time.Time, end time.Time) string

func PrepareDir

func PrepareDir(path string) error

PrepareDir ensures that the specified directory path exists. If the directory does not exist, it attempts to create it.

func SplitInt64ToTwoInt32

func SplitInt64ToTwoInt32(input int64) (int64, int64)

func Str2List

func Str2List(str string, sep string) []string

func TimeRangeOf

func TimeRangeOf(str string) (start, end time.Time, ok bool)

TimeOf 解析各种格式的时间点 支持以下格式: 1. 时间戳(秒): 1609459200 2. 标准日期: 20060102, 2006-01-02 3. 带时间的日期: 20060102/15:04, 2006-01-02/15:04 4. 完整时间: 20060102150405 5. RFC3339: 2006-01-02T15:04:05Z07:00 6. 相对时间: 5h-ago, 3d-ago, 1w-ago, 1m-ago, 1y-ago (小时、天、周、月、年) 7. 自然语言: now, today, yesterday 8. 年份: 2006 9. 月份: 200601, 2006-01 10. 季度: 2006Q1, 2006Q2, 2006Q3, 2006Q4 11. 年月日时分: 200601021504 TimeRangeOf 解析各种格式的时间范围 支持以下格式: 1. 单个时间点: 根据时间粒度确定合适的时间范围

  • 精确到秒/分钟/小时: 扩展为当天范围
  • 精确到天: 当天 00:00:00 ~ 23:59:59
  • 精确到月: 当月第一天 ~ 最后一天
  • 精确到季度: 季度第一天 ~ 最后一天
  • 精确到年: 当年第一天 ~ 最后一天

2. 时间区间: 2006-01-01~2006-01-31, 2006-01-01,2006-01-31, 2006-01-01 to 2006-01-31 3. 相对时间: last-7d, last-30d, last-3m, last-1y (最近7天、30天、3个月、1年) 4. 特定时间段: today, yesterday, this-week, last-week, this-month, last-month, this-year, last-year 5. all: 表示所有时间

Types

type TimeGranularity

type TimeGranularity int

时间粒度常量

const (
	GranularityUnknown TimeGranularity = iota // 未知粒度
	GranularitySecond                         // 精确到秒
	GranularityMinute                         // 精确到分钟
	GranularityHour                           // 精确到小时
	GranularityDay                            // 精确到天
	GranularityMonth                          // 精确到月
	GranularityQuarter                        // 精确到季度
	GranularityYear                           // 精确到年
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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