Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
DateTimeFormatter.h
浏览该文件的文档.
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
21#pragma once
22
23#include "sese/Config.h"
25
26#include <map>
27#include <array>
28
29#ifdef _MSC_VER
30#pragma warning(disable : 4251)
31#endif
32namespace sese {
33
34class DateTime;
35
36namespace text {
37
72 public:
73 static std::string format(const DateTime &date_time, const std::string &pattern = TIME_DEFAULT_PATTERN);
74
75 static std::string format(const std::unique_ptr<DateTime> &date_time, const std::string &pattern = TIME_DEFAULT_PATTERN);
76
85 static uint64_t parseFromGreenwich(const std::string &text);
86
98 static uint64_t parseFromISO8601(const std::string &text);
99
100 protected:
101 static int mon2number(const std::string &text);
102
103 static const std::map<std::string, uint8_t> MON_MAP;
104 static const std::array<std::string, 12> MON_ARRAY;
105
106 static const std::map<std::string, uint8_t> MONTH_MAP;
107 static const std::array<std::string, 12> MONTH_ARRAY;
108
109 static const std::array<std::string, 7> WK_DAY;
110 static const std::array<std::string, 7> WEEK_DAY;
111 };
112} // namespace text
113} // namespace sese