forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypeTime.cpp
More file actions
50 lines (40 loc) · 1.16 KB
/
DataTypeTime.cpp
File metadata and controls
50 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <DataTypes/DataTypeTime.h>
#include <DataTypes/Serializations/SerializationDateTime.h>
#include <Common/SipHash.h>
#include <IO/Operators.h>
#include <IO/WriteBufferFromString.h>
namespace DB
{
DataTypeTime::DataTypeTime(const String & time_zone_name)
: TimezoneMixin(time_zone_name)
{
}
DataTypeTime::DataTypeTime(const TimezoneMixin & time_zone_)
: TimezoneMixin(time_zone_)
{
}
String DataTypeTime::doGetName() const
{
if (!has_explicit_time_zone)
return "Time";
WriteBufferFromOwnString out;
out << "Time(" << quote << time_zone.getTimeZone() << ")";
return out.str();
}
void DataTypeTime::updateHashImpl(SipHash & hash) const
{
hash.update(has_explicit_time_zone);
if (has_explicit_time_zone)
hash.update(time_zone.getTimeZone());
}
bool DataTypeTime::equals(const IDataType & rhs) const
{
/// Time with different timezones are equal, because:
/// "all types with different time zones are equivalent and may be used interchangingly."
return typeid(rhs) == typeid(*this);
}
SerializationPtr DataTypeTime::doGetDefaultSerialization() const
{
return std::make_shared<SerializationTime>(*this);
}
}