Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
01af2778
Commit
01af2778
authored
Feb 02, 2021
by
Max Kellermann
Committed by
Max Kellermann
Feb 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/ISO8601: throw std::invalid_argument on error
Throwing std::runtime_error was slightly wrong.
parent
ad03c707
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
ISO8601.cxx
src/time/ISO8601.cxx
+7
-7
No files found.
src/time/ISO8601.cxx
View file @
01af2778
...
...
@@ -77,14 +77,14 @@ ParseTimeZoneOffsetRaw(const char *&s)
++
s
;
minutes
=
std
::
strtoul
(
s
,
&
endptr
,
10
);
if
(
endptr
!=
s
+
2
)
throw
std
::
runtime_error
(
"Failed to parse time zone offset"
);
throw
std
::
invalid_argument
(
"Failed to parse time zone offset"
);
s
=
endptr
;
}
return
std
::
make_pair
(
hours
,
minutes
);
}
else
throw
std
::
runtime_error
(
"Failed to parse time zone offset"
);
throw
std
::
invalid_argument
(
"Failed to parse time zone offset"
);
}
static
std
::
chrono
::
system_clock
::
duration
...
...
@@ -97,10 +97,10 @@ ParseTimeZoneOffset(const char *&s)
auto
raw
=
ParseTimeZoneOffsetRaw
(
s
);
if
(
raw
.
first
>
13
)
throw
std
::
runtime_error
(
"Time offset hours out of range"
);
throw
std
::
invalid_argument
(
"Time offset hours out of range"
);
if
(
raw
.
second
>=
60
)
throw
std
::
runtime_error
(
"Time offset minutes out of range"
);
throw
std
::
invalid_argument
(
"Time offset minutes out of range"
);
std
::
chrono
::
system_clock
::
duration
d
=
std
::
chrono
::
hours
(
raw
.
first
);
d
+=
std
::
chrono
::
minutes
(
raw
.
second
);
...
...
@@ -207,7 +207,7 @@ ParseISO8601(const char *s)
/* try without field separators */
end
=
strptime
(
s
,
"%Y%m%d"
,
&
tm
);
if
(
end
==
nullptr
)
throw
std
::
runtime_error
(
"Failed to parse date"
);
throw
std
::
invalid_argument
(
"Failed to parse date"
);
}
s
=
end
;
...
...
@@ -220,7 +220,7 @@ ParseISO8601(const char *s)
s
=
ParseTimeOfDay
(
s
,
tm
,
precision
);
if
(
s
==
nullptr
)
throw
std
::
runtime_error
(
"Failed to parse time of day"
);
throw
std
::
invalid_argument
(
"Failed to parse time of day"
);
}
auto
tp
=
TimeGm
(
tm
);
...
...
@@ -232,7 +232,7 @@ ParseISO8601(const char *s)
tp
-=
ParseTimeZoneOffset
(
s
);
if
(
*
s
!=
0
)
throw
std
::
runtime_error
(
"Garbage at end of time stamp"
);
throw
std
::
invalid_argument
(
"Garbage at end of time stamp"
);
return
std
::
make_pair
(
tp
,
precision
);
#endif
/* !_WIN32 */
...
...
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