Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7876d75

Browse files
author
Charlie Barto
authored
Merge pull request #1571 from BillyONeal/filetime_zero
Added the ability to parse and emit the NT Epoch 1601年01月01日T00:00:00Z
2 parents 41e7d00 + a3da3e9 commit 7876d75

File tree

5 files changed

+200
-115
lines changed

5 files changed

+200
-115
lines changed

‎Release/include/cpprest/asyncrt_utils.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,21 @@ class datetime
603603
}
604604
}
605605

606-
datetime() : m_interval(0) {}
606+
datetime() : m_interval(0) {}
607607

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

614+
/// <summary>
615+
/// Creates <c>datetime</c> from a string representing time in UTC in RFC 1123 or ISO 8601 format.
616+
/// </summary>
617+
/// <returns>Returns <c>datetime::maximum()</c> if not successful.</returns>
618+
static _ASYNCRTIMP datetime __cdecl from_string_maximum_error(const utility::string_t& timestring,
619+
date_format format = RFC_1123);
620+
614621
/// <summary>
615622
/// Returns a string representation of the <c>datetime</c>.
616623
/// </summary>
@@ -621,20 +628,22 @@ class datetime
621628
/// </summary>
622629
interval_type to_interval() const { return m_interval; }
623630

631+
static datetime from_interval(interval_type interval) { return datetime(interval); }
632+
624633
datetime operator-(interval_type value) const { return datetime(m_interval - value); }
625634

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

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

630639
bool operator!=(const datetime& dt) const { return !(*this == dt); }
631-
640+
632641
bool operator>(const datetime& dt) const { return this->m_interval > dt.m_interval; }
633-
642+
634643
bool operator<(const datetime& dt) const { return this->m_interval < dt.m_interval; }
635-
644+
636645
bool operator>=(const datetime& dt) const { return this->m_interval >= dt.m_interval; }
637-
646+
638647
bool operator<=(const datetime& dt) const { return this->m_interval <= dt.m_interval; }
639648

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

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

661+
static datetime maximum() { return datetime(static_cast<interval_type>(-1)); }
662+
652663
private:
653664
friend int operator-(datetime t1, datetime t2);
654665

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

661672
// Private constructor. Use static methods to create an instance.
662-
datetime(interval_type interval) : m_interval(interval) {}
673+
datetime(interval_type interval) : m_interval(interval) {}
663674

664675
// Storing as hundreds of nanoseconds 10e-7, i.e. 1 here equals 100ns.
665676
interval_type m_interval;

‎Release/include/cpprest/streams.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "cpprest/astreambuf.h"
1919
#include <iosfwd>
20+
#include <cstdio>
2021

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

14351436
if (state->exponent_number >= 0)
14361437
{
1437-
result *= pow(FloatingPoint(10.0), state->exponent_number);
1438+
result *= static_cast<FloatingPoint>(
1439+
std::pow(static_cast<FloatingPoint>(10.0), static_cast<FloatingPoint>(state->exponent_number)));
14381440

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

1450-
result /= pow(FloatingPoint(10.0), -state->exponent_number);
1452+
result /= static_cast<FloatingPoint>(
1453+
std::pow(static_cast<FloatingPoint>(10.0), static_cast<FloatingPoint>(-state->exponent_number)));
14511454

14521455
if (!is_zero && result > -std::numeric_limits<FloatingPoint>::denorm_min() &&
14531456
result < std::numeric_limits<FloatingPoint>::denorm_min())

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /