1#include <Functions/IFunctionImpl.h>
2#include <Functions/FunctionFactory.h>
3#include <common/DateLUT.h>
4#include <Core/Field.h>
5#include <DataTypes/DataTypeString.h>
6
7
8namespace DB
9{
10
11
12/** Returns the server time zone.
13 */
14class FunctionTimeZone : public IFunction
15{
16public:
17 static constexpr auto name = "timezone";
18 static FunctionPtr create(const Context &)
19 {
20 return std::make_shared<FunctionTimeZone>();
21 }
22
23 String getName() const override
24 {
25 return name;
26 }
27 size_t getNumberOfArguments() const override
28 {
29 return 0;
30 }
31
32 DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
33 {
34 return std::make_shared<DataTypeString>();
35 }
36
37 bool isDeterministic() const override { return false; }
38
39 void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override
40 {
41 block.getByPosition(result).column = DataTypeString().createColumnConst(input_rows_count, DateLUT::instance().getTimeZone());
42 }
43};
44
45
46void registerFunctionTimeZone(FunctionFactory & factory)
47{
48 factory.registerFunction<FunctionTimeZone>();
49}
50
51}
52