Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/microsoft/cpprestsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
barcharcraz committed Feb 1, 2021
2 parents 42dbc76 + 7876d75 commit c8bf335
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 115 deletions.
25 changes: 18 additions & 7 deletions Release/include/cpprest/asyncrt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,21 @@ class datetime
}
}

datetime() : m_interval(0) {}
datetime() : m_interval(0) { }

/// <summary>
/// Creates <c>datetime</c> from a string representing time in UTC in RFC 1123 format.
/// Creates <c>datetime</c> from a string representing time in UTC in RFC 1123 or ISO 8601 format.
/// </summary>
/// <returns>Returns a <c>datetime</c> of zero if not successful.</returns>
static _ASYNCRTIMP datetime __cdecl from_string(const utility::string_t& timestring, date_format format = RFC_1123);

/// <summary>
/// Creates <c>datetime</c> from a string representing time in UTC in RFC 1123 or ISO 8601 format.
/// </summary>
/// <returns>Returns <c>datetime::maximum()</c> if not successful.</returns>
static _ASYNCRTIMP datetime __cdecl from_string_maximum_error(const utility::string_t& timestring,
date_format format = RFC_1123);

/// <summary>
/// Returns a string representation of the <c>datetime</c>.
/// </summary>
Expand All @@ -621,20 +628,22 @@ class datetime
/// </summary>
interval_type to_interval() const { return m_interval; }

static datetime from_interval(interval_type interval) { return datetime(interval); }

datetime operator-(interval_type value) const { return datetime(m_interval - value); }

datetime operator+(interval_type value) const { return datetime(m_interval + value); }

bool operator==(datetime dt) const { return m_interval == dt.m_interval; }

bool operator!=(const datetime& dt) const { return !(*this == dt); }

bool operator>(const datetime& dt) const { return this->m_interval > dt.m_interval; }

bool operator<(const datetime& dt) const { return this->m_interval < dt.m_interval; }

bool operator>=(const datetime& dt) const { return this->m_interval >= dt.m_interval; }

bool operator<=(const datetime& dt) const { return this->m_interval <= dt.m_interval; }

static interval_type from_milliseconds(unsigned int milliseconds) { return milliseconds * _msTicks; }
Expand All @@ -649,6 +658,8 @@ class datetime

bool is_initialized() const { return m_interval != 0; }

static datetime maximum() { return datetime(static_cast<interval_type>(-1)); }

private:
friend int operator-(datetime t1, datetime t2);

Expand All @@ -659,7 +670,7 @@ class datetime
static const interval_type _dayTicks = 24 * 60 * 60 * _secondTicks;

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

// Storing as hundreds of nanoseconds 10e-7, i.e. 1 here equals 100ns.
interval_type m_interval;
Expand Down
7 changes: 5 additions & 2 deletions Release/include/cpprest/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "cpprest/astreambuf.h"
#include <iosfwd>
#include <cstdio>

namespace Concurrency
{
Expand Down Expand Up @@ -1434,7 +1435,8 @@ static pplx::task<FloatingPoint> _extract_result(std::shared_ptr<_double_state<F

if (state->exponent_number >= 0)
{
result *= pow(FloatingPoint(10.0), state->exponent_number);
result *= static_cast<FloatingPoint>(
std::pow(static_cast<FloatingPoint>(10.0), static_cast<FloatingPoint>(state->exponent_number)));

#pragma push_macro("max")
#undef max
Expand All @@ -1447,7 +1449,8 @@ static pplx::task<FloatingPoint> _extract_result(std::shared_ptr<_double_state<F
{
bool is_zero = (result == 0);

result /= pow(FloatingPoint(10.0), -state->exponent_number);
result /= static_cast<FloatingPoint>(
std::pow(static_cast<FloatingPoint>(10.0), static_cast<FloatingPoint>(-state->exponent_number)));

if (!is_zero && result > -std::numeric_limits<FloatingPoint>::denorm_min() &&
result < std::numeric_limits<FloatingPoint>::denorm_min())
Expand Down
Loading

0 comments on commit c8bf335

Please sign in to comment.