Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
a5a9805a
Commit
a5a9805a
authored
Nov 25, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First stub at the datetime format parser
parent
645c76a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
include/fmt/time.h
include/fmt/time.h
+50
-1
No files found.
include/fmt/time.h
View file @
a5a9805a
// Formatting library for C++ - time formatting
// Formatting library for C++ - time formatting
//
//
// Copyright (c) 2012 -
2016
, Victor Zverovich
// Copyright (c) 2012 -
present
, Victor Zverovich
// All rights reserved.
// All rights reserved.
//
//
// For the license information refer to format.h.
// For the license information refer to format.h.
...
@@ -22,7 +22,56 @@ inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); }
...
@@ -22,7 +22,56 @@ inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); }
inline
null
<>
localtime_s
(...)
{
return
null
<>
();
}
inline
null
<>
localtime_s
(...)
{
return
null
<>
();
}
inline
null
<>
gmtime_r
(...)
{
return
null
<>
();
}
inline
null
<>
gmtime_r
(...)
{
return
null
<>
();
}
inline
null
<>
gmtime_s
(...)
{
return
null
<>
();
}
inline
null
<>
gmtime_s
(...)
{
return
null
<>
();
}
// Parses a put_time-like format string and invokes handler actions.
template
<
bool
IS_CONSTEXPR
,
typename
Char
,
typename
Handler
>
FMT_CONSTEXPR
void
parse_datetime_format
(
basic_string_view
<
Char
>
format_str
,
Handler
&&
handler
)
{
auto
begin
=
format_str
.
data
();
auto
end
=
begin
+
format_str
.
size
();
auto
ptr
=
begin
;
while
(
ptr
!=
end
)
{
auto
c
=
*
ptr
;
if
(
c
==
'}'
)
break
;
if
(
c
!=
'%'
)
{
++
ptr
;
continue
;
}
if
(
begin
!=
ptr
)
handler
.
on_text
(
begin
,
ptr
);
c
=
*++
ptr
;
begin
=
ptr
;
switch
(
c
)
{
case
'%'
:
handler
.
on_text
(
ptr
,
ptr
+
1
);
break
;
// Day of the week:
case
'a'
:
handler
.
on_abbr_weekday
();
break
;
case
'A'
:
handler
.
on_full_weekday
();
break
;
case
'w'
:
handler
.
on_dec0_weekday
();
break
;
case
'u'
:
handler
.
on_dec1_weekday
();
break
;
// Month:
case
'b'
:
case
'h'
:
handler
.
on_abbr_month
();
break
;
case
'B'
:
handler
.
on_full_month
();
break
;
// TODO: parse more format specifiers
}
}
if
(
begin
!=
ptr
)
handler
.
on_text
(
begin
,
ptr
);
}
}
}
// namespace internal
// Thread-safe replacement for std::localtime
// Thread-safe replacement for std::localtime
inline
std
::
tm
localtime
(
std
::
time_t
time
)
{
inline
std
::
tm
localtime
(
std
::
time_t
time
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment