Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
DateTimeFormatter.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
22#pragma once
23
24#include "sese/Config.h"
26
27#include <map>
28#include <array>
29
30#ifdef _MSC_VER
31#pragma warning(disable : 4251)
32#endif
33namespace sese {
34
35class DateTime;
36
37namespace text {
38
73 public:
74 static std::string format(const DateTime &date_time, const std::string &pattern = TIME_DEFAULT_PATTERN);
75
76 static std::string format(const std::unique_ptr<DateTime> &date_time, const std::string &pattern = TIME_DEFAULT_PATTERN);
77
86 static uint64_t parseFromGreenwich(const std::string &text);
87
99 static uint64_t parseFromISO8601(const std::string &text);
101 protected:
102 static int mon2number(const std::string &text);
103
104 static const std::map<std::string, uint8_t> MON_MAP;
105 static const std::array<std::string, 12> MON_ARRAY;
106
107 static const std::map<std::string, uint8_t> MONTH_MAP;
108 static const std::array<std::string, 12> MONTH_ARRAY;
109
110 static const std::array<std::string, 7> WK_DAY;
111 static const std::array<std::string, 7> WEEK_DAY;
112 };
113} // namespace text
114} // namespace sese