1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-27 23:18:34 +02:00
Files
starter/postgres_func/postgres_func.go

37 lines
937 B
Go
Raw Normal View History

2023-03-17 11:20:09 +03:00
package postgres_func
2025-01-16 15:21:11 +03:00
import (
"strings"
"time"
)
2023-03-17 11:20:09 +03:00
2025-01-16 15:21:11 +03:00
// StringSQLTime - преобразует время в строку в формате SQL
2023-03-17 11:20:09 +03:00
func StringSQLTime(time1 time.Time) string {
Otvet := ""
2023-06-01 18:02:36 +03:00
format := "2006-01-02T15:04:05.999999Z07:00"
Otvet = "'" + time1.Format(format) + "'"
//Otvet = "'" + time1.Format(time.RFC3339Nano) + "'"
2023-03-17 11:20:09 +03:00
return Otvet
}
2023-04-25 17:28:10 +03:00
2025-01-16 15:21:11 +03:00
// StringSQLTime - преобразует время в строку в формате SQL, без часового пояса
2023-04-25 17:28:10 +03:00
func StringSQLTime_WithoutTimeZone(time1 time.Time) string {
Otvet := ""
2023-06-01 18:02:36 +03:00
format := "2006-01-02T15:04:05.999999+00:00"
2023-04-25 17:28:10 +03:00
Otvet = "'" + time1.Format(format) + "'"
return Otvet
}
2025-01-16 15:21:11 +03:00
// ReplaceSchemaName - заменяет имя схемы в тексте SQL
func ReplaceSchemaName(TextSQL, SchemaNameFrom, SchemaNameTo string) string {
Otvet := TextSQL
Otvet = strings.ReplaceAll(Otvet, SchemaNameFrom+".", SchemaNameTo+".")
return Otvet
}