MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
polyglot_date.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, 2025, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License, version 2.0, for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef ROUTER_SRC_JIT_EXECUTOR_SRC_OBJECTS_POLYGLOT_DATE_H_
27#define ROUTER_SRC_JIT_EXECUTOR_SRC_OBJECTS_POLYGLOT_DATE_H_
28
29#include <string>
30
33
34namespace shcore {
35namespace polyglot {
36
37class Date : public Object_bridge {
38 public:
39 Date(const Date &date);
40 Date(int year, int month, int day, int hour, int min, int sec, int usec);
41 Date(int hour, int min, int sec, int usec);
42 Date(int year, int month, int day);
43
44 std::string class_name() const override { return "Date"; }
45
46 std::string &append_descr(std::string &s_out, int indent = -1,
47 int quote_strings = 0) const override;
48 std::string &append_repr(std::string &s_out) const override;
49 void append_json(shcore::JSON_dumper &dumper) const override;
50
51 virtual bool operator==(const Object_bridge &other) const;
52 bool operator==(const Date &other) const;
53
54 int64_t as_ms() const;
55
56 int get_year() const { return _year; }
57 int get_month() const { return _month + 1; }
58 int get_day() const { return _day; }
59 int get_hour() const { return _hour; }
60 int get_min() const { return _min; }
61 int get_sec() const { return _sec; }
62 int get_usec() const { return _usec; }
63
64 bool has_time() const { return _has_time; }
65 bool has_date() const { return _has_date; }
66
67 public:
68 static Date unrepr(const std::string &s);
69 static Date from_ms(int64_t ms_since_epoch);
70
71 private:
72 void validate();
73
74 int _year;
75 int _month;
76 int _day;
77 int _hour;
78 int _min;
79 int _sec;
80 int _usec;
83};
84
85} // namespace polyglot
86} // namespace shcore
87
88#endif // ROUTER_SRC_JIT_EXECUTOR_SRC_OBJECTS_POLYGLOT_DATE_H_
Definition: utils_json.h:49
Definition: polyglot_date.h:37
std::string class_name() const override
Definition: polyglot_date.h:44
bool has_time() const
Definition: polyglot_date.h:64
int get_month() const
Definition: polyglot_date.h:57
int _hour
Definition: polyglot_date.h:77
void validate()
Definition: polyglot_date.cc:221
int _min
Definition: polyglot_date.h:78
std::string & append_repr(std::string &s_out) const override
Definition: polyglot_date.cc:133
int _sec
Definition: polyglot_date.h:79
int _usec
Definition: polyglot_date.h:80
bool _has_date
Definition: polyglot_date.h:82
int _day
Definition: polyglot_date.h:76
void append_json(shcore::JSON_dumper &dumper) const override
Definition: polyglot_date.cc:137
static Date from_ms(int64_t ms_since_epoch)
Definition: polyglot_date.cc:206
int get_sec() const
Definition: polyglot_date.h:61
bool has_date() const
Definition: polyglot_date.h:65
static Date unrepr(const std::string &s)
Definition: polyglot_date.cc:165
int get_year() const
Definition: polyglot_date.h:56
int get_usec() const
Definition: polyglot_date.h:62
int get_day() const
Definition: polyglot_date.h:58
virtual bool operator==(const Object_bridge &other) const
Definition: polyglot_date.cc:92
int get_min() const
Definition: polyglot_date.h:60
int _year
Definition: polyglot_date.h:74
int64_t as_ms() const
Definition: polyglot_date.cc:191
int _month
Definition: polyglot_date.h:75
Date(const Date &date)
Definition: polyglot_date.cc:38
int get_hour() const
Definition: polyglot_date.h:59
bool _has_time
Definition: polyglot_date.h:81
std::string & append_descr(std::string &s_out, int indent=-1, int quote_strings=0) const override
Definition: polyglot_date.cc:107
Definition: polyglot_object_bridge.h:38
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:168
Definition: file_system_exceptions.h:34