Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s
- 新增 9 张房屋相关数据表(社区/楼宇/房源/价格快照/交易/设施/社区设施/学区/偏好) - 添加菜单权限种子数据并绑定超级管理员角色 - 生成 DAO 层代码和实体对象 - 实现房屋模块 API 接口(社区/房源/看板)和控制器服务层 - 支持多平台软关联匹配、笋盘标记和低可信度标记功能 - 更新超级管理员账号为 xxcool/xxCool@2026 - 调整 RBAC 菜单结构,移除管理员管理功能,新增日志管理菜单 - 修复 RBAC 安全漏洞,确保禁用角色权限失效 - 重构认证模块,将登录相关接口迁移到统一包结构下 - 移除废弃的管理模块和工具类接口定义 - 为通用工具包添加中文注释和文档说明
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
// Package timex 基于 gtime 提供时间格式化与计算工具。
|
||
package timex
|
||
|
||
import (
|
||
"github.com/gogf/gf/v2/os/gtime"
|
||
)
|
||
|
||
const (
|
||
// LayoutDateTime 是常用日期时间格式:2006-01-02 15:04:05。
|
||
LayoutDateTime = "2006-01-02 15:04:05"
|
||
// LayoutDate 是常用日期格式:2006-01-02。
|
||
LayoutDate = "2006-01-02"
|
||
)
|
||
|
||
// Now 返回当前时间。
|
||
func Now() *gtime.Time {
|
||
return gtime.Now()
|
||
}
|
||
|
||
// Format 按给定 Go 布局格式化 t,
|
||
// layout 为空时使用 LayoutDateTime。
|
||
//
|
||
// 注意:gtime v2.10.2 的 Format() 接收 PHP 风格格式("Y-m-d H:i:s"),
|
||
// 因此本工具改用接受 Go 布局的 Layout() 方法。
|
||
func Format(t *gtime.Time, layout ...string) string {
|
||
ly := LayoutDateTime
|
||
if len(layout) > 0 && layout[0] != "" {
|
||
ly = layout[0]
|
||
}
|
||
return t.Layout(ly)
|
||
}
|
||
|
||
// Timestamp 返回当前 Unix 秒级时间戳。
|
||
func Timestamp() int64 {
|
||
return gtime.Now().Timestamp()
|
||
}
|
||
|
||
// StartOfDay 返回 t 所在日期的零点(00:00:00)。
|
||
func StartOfDay(t *gtime.Time) *gtime.Time {
|
||
return gtime.NewFromStr(t.Layout(LayoutDate) + " 00:00:00")
|
||
}
|
||
|
||
// EndOfDay 返回 t 所在日期的末尾(23:59:59)。
|
||
func EndOfDay(t *gtime.Time) *gtime.Time {
|
||
return gtime.NewFromStr(t.Layout(LayoutDate) + " 23:59:59")
|
||
}
|