Skip to content

Commit f10d9f8

Browse files
authored
Rewrite date formatting and parsing (#1076)
This overhauls the RFC 1123 and ISO 8601 parsing with bits copied from the autorest C prototype, giving more consistent behavior across platforms, and removing unintended locale dependencies. (For example, before on POSIX on a German machine we might emit Die, 19 Mär 2019 09:59:57 which would be rejected by servers) There is a subtle breaking change in that we previously accepted a time with no date, e.g. "12:12:12Z", and this change rejects that. However, such input is not a valid ISO 8601 input, and we were crazy about how we handled it before. Before, on Windows we would fill in the date with whatever the current date is, but on POSIX we would fill in January 1, 1970. Considering this was never consistent, and considering 99.999% of internet customers are going to be using RFC 3339 which requires all the components, I've dropped that special case. Lots of tests also added.
1 parent a325079 commit f10d9f8

File tree

4 files changed

+896
-435
lines changed

4 files changed

+896
-435
lines changed

Release/include/cpprest/asyncrt_utils.h

-10
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,6 @@ class datetime
630630
static const interval_type _hourTicks = 60 * 60 * _secondTicks;
631631
static const interval_type _dayTicks = 24 * 60 * 60 * _secondTicks;
632632

633-
#ifdef _WIN32
634-
// void* to avoid pulling in windows.h
635-
static _ASYNCRTIMP bool __cdecl system_type_to_datetime(/*SYSTEMTIME*/ void* psysTime,
636-
uint64_t seconds,
637-
datetime* pdt);
638-
#else
639-
static datetime timeval_to_datetime(const timeval& time);
640-
#endif
641-
642633
// Private constructor. Use static methods to create an instance.
643634
datetime(interval_type interval) : m_interval(interval) {}
644635

@@ -699,7 +690,6 @@ class nonce_generator
699690
void set_length(int length) { m_length = length; }
700691

701692
private:
702-
static const utility::string_t c_allowed_chars;
703693
std::mt19937 m_random;
704694
int m_length;
705695
};

Release/src/pch/stdafx.h

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
#undef BOOST_NO_CXX11_NULLPTR
6262
#endif
6363
#include "boost/bind/bind.hpp"
64-
#include "boost/date_time/posix_time/posix_time_types.hpp"
6564
#include "boost/thread/condition_variable.hpp"
6665
#include "boost/thread/mutex.hpp"
6766
#include <fcntl.h>

0 commit comments

Comments
 (0)