Download model/db_time.go from Kyou0203/test-napi: direct link, hf CLI and curl.
- Browser
- Download file 578 Bytes
-
https://huggingface.co/spaces/Kyou0203/test-napi/resolve/main/model/db_time.go
- Command line
-
hf download hf://spaces/Kyou0203/test-napi/model/db_time.go
-
curl -L -o db_time.go https://huggingface.co/spaces/Kyou0203/test-napi/resolve/main/model/db_time.go
578 Bytes
| package model | |
| import "github.com/QuantumNous/new-api/common" | |
| // GetDBTimestamp returns a UNIX timestamp from database time. | |
| // Falls back to application time on error. | |
| func GetDBTimestamp() int64 { | |
| var ts int64 | |
| var err error | |
| switch { | |
| case common.UsingPostgreSQL: | |
| err = DB.Raw("SELECT EXTRACT(EPOCH FROM NOW())::bigint").Scan(&ts).Error | |
| case common.UsingSQLite: | |
| err = DB.Raw("SELECT strftime('%s','now')").Scan(&ts).Error | |
| default: | |
| err = DB.Raw("SELECT UNIX_TIMESTAMP()").Scan(&ts).Error | |
| } | |
| if err != nil || ts <= 0 { | |
| return common.GetTimestamp() | |
| } | |
| return ts | |
| } | |