File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed
tests/sqllogictests/suites/query/02_function Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -382,8 +382,8 @@ impl AddTimesImpl {
382
382
}
383
383
384
384
#[ inline]
385
- pub fn today_date ( ) -> i32 {
386
- let now = Utc :: now ( ) ;
385
+ pub fn today_date ( tz : TzLUT ) -> i32 {
386
+ let now = Utc :: now ( ) . with_timezone ( & tz . tz ) ;
387
387
NaiveDate :: from_ymd_opt ( now. year ( ) , now. month ( ) , now. day ( ) )
388
388
. unwrap ( )
389
389
. signed_duration_since ( NaiveDate :: from_ymd_opt ( 1970 , 1 , 1 ) . unwrap ( ) )
Original file line number Diff line number Diff line change @@ -837,19 +837,19 @@ fn register_real_time_functions(registry: &mut FunctionRegistry) {
837
837
registry. register_0_arg_core :: < DateType , _ , _ > (
838
838
"today" ,
839
839
|_| FunctionDomain :: Full ,
840
- |_ | Value :: Scalar ( today_date ( ) ) ,
840
+ |ctx | Value :: Scalar ( today_date ( ctx . func_ctx . tz ) ) ,
841
841
) ;
842
842
843
843
registry. register_0_arg_core :: < DateType , _ , _ > (
844
844
"yesterday" ,
845
845
|_| FunctionDomain :: Full ,
846
- |_ | Value :: Scalar ( today_date ( ) - 1 ) ,
846
+ |ctx | Value :: Scalar ( today_date ( ctx . func_ctx . tz ) - 1 ) ,
847
847
) ;
848
848
849
849
registry. register_0_arg_core :: < DateType , _ , _ > (
850
850
"tomorrow" ,
851
851
|_| FunctionDomain :: Full ,
852
- |_ | Value :: Scalar ( today_date ( ) + 1 ) ,
852
+ |ctx | Value :: Scalar ( today_date ( ctx . func_ctx . tz ) + 1 ) ,
853
853
) ;
854
854
}
855
855
Original file line number Diff line number Diff line change @@ -4,12 +4,34 @@ drop table if exists t all
4
4
statement ok
5
5
set timezone = 'UTC'
6
6
7
- query B
8
- SELECT today() >= 18869::DATE
7
+ query I
8
+ select to_string( today())=substr(to_string(now()),1,10);
9
9
----
10
10
1
11
11
12
+ statement ok
13
+ set timezone = 'Asia/Shanghai'
12
14
15
+ query I
16
+ select to_string(today())=substr(to_string(now()),1,10);
17
+ ----
18
+ 1
19
+
20
+ statement ok
21
+ set timezone = 'America/Los_Angeles'
22
+
23
+ query I
24
+ select to_string(today())=substr(to_string(now()),1,10);
25
+ ----
26
+ 1
27
+
28
+ statement ok
29
+ set timezone = 'UTC'
30
+
31
+ query B
32
+ SELECT today() >= 18869::DATE
33
+ ----
34
+ 1
13
35
14
36
query B
15
37
SELECT now() >= 1630295616::TIMESTAMP
You can’t perform that action at this time.
0 commit comments