Merge pull request #1091 from pinzi/SqlSugar5

修改QuestDB数据库时获取服务器时间为当前时区时间
This commit is contained in:
果糖网 2022-10-22 13:52:28 +08:00 committed by GitHub
commit 401ad53369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 8 deletions

View File

@ -24,14 +24,32 @@ namespace SqlSugar
{
get
{
return "now()";
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
//https://questdb.io/docs/reference/function/date-time/#to_timezone
//SELECT
// now(), --2022-10-21T07:19:50.680134Z
// systimestamp(), --2022-10-21T07:19:50.680278Z
// sysdate(), --2022-10-21T07:19:50.679Z
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
return $"to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
}
}
public override string FullSqlDateNow
{
get
{
return "select now()";
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
//https://questdb.io/docs/reference/function/date-time/#to_timezone
//SELECT
// now(), --2022-10-21T07:19:50.680134Z
// systimestamp(), --2022-10-21T07:19:50.680278Z
// sysdate(), --2022-10-21T07:19:50.679Z
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
return $"SELECT to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
}
}

View File

@ -24,14 +24,32 @@ namespace SqlSugar
{
get
{
return "now()";
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
//https://questdb.io/docs/reference/function/date-time/#to_timezone
//SELECT
// now(), --2022-10-21T07:19:50.680134Z
// systimestamp(), --2022-10-21T07:19:50.680278Z
// sysdate(), --2022-10-21T07:19:50.679Z
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
return $"to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
}
}
public override string FullSqlDateNow
{
get
{
return "select now()";
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
//https://questdb.io/docs/reference/function/date-time/#to_timezone
//SELECT
// now(), --2022-10-21T07:19:50.680134Z
// systimestamp(), --2022-10-21T07:19:50.680278Z
// sysdate(), --2022-10-21T07:19:50.679Z
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
return $"SELECT to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
}
}