Skip to content

Commit

Permalink
Rewrite date formatting and parsing (#1076)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BillyONeal authored Mar 21, 2019
1 parent a325079 commit f10d9f8
Show file tree
Hide file tree
Showing 4 changed files with 896 additions and 435 deletions.
10 changes: 0 additions & 10 deletions Release/include/cpprest/asyncrt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,6 @@ class datetime
static const interval_type _hourTicks = 60 * 60 * _secondTicks;
static const interval_type _dayTicks = 24 * 60 * 60 * _secondTicks;

#ifdef _WIN32
// void* to avoid pulling in windows.h
static _ASYNCRTIMP bool __cdecl system_type_to_datetime(/*SYSTEMTIME*/ void* psysTime,
uint64_t seconds,
datetime* pdt);
#else
static datetime timeval_to_datetime(const timeval& time);
#endif

// Private constructor. Use static methods to create an instance.
datetime(interval_type interval) : m_interval(interval) {}

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

private:
static const utility::string_t c_allowed_chars;
std::mt19937 m_random;
int m_length;
};
Expand Down
1 change: 0 additions & 1 deletion Release/src/pch/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#undef BOOST_NO_CXX11_NULLPTR
#endif
#include "boost/bind/bind.hpp"
#include "boost/date_time/posix_time/posix_time_types.hpp"
#include "boost/thread/condition_variable.hpp"
#include "boost/thread/mutex.hpp"
#include <fcntl.h>
Expand Down
Loading

0 comments on commit f10d9f8

Please sign in to comment.