@@ -33,13 +33,17 @@ using namespace Windows::Storage::Streams;
33
33
#if !defined(_MS_WINDOWS)
34
34
#include < boost/date_time/posix_time/posix_time.hpp>
35
35
#include < boost/date_time/posix_time/posix_time_io.hpp>
36
+ #ifdef __APPLE__
36
37
// GCC 4.8 does not support regex, use boost. TODO: switch to std::regex in GCC 4.9
38
+ // Clang already supports std::regex
37
39
#include < boost/regex.hpp>
40
+ #endif
38
41
using namespace boost ::locale::conv;
39
42
#endif
40
43
41
44
#ifdef __APPLE__
42
45
#include < CoreFoundation/CoreFoundation.h>
46
+ #include < regex>
43
47
#endif
44
48
45
49
using namespace web ;
@@ -800,16 +804,28 @@ datetime __cdecl datetime::from_string(const utility::string_t& dateString, date
800
804
}
801
805
else
802
806
{
807
+ #ifdef __APPLE__
808
+ // Try to extract the fractional second from the timestamp
809
+ std::regex r_frac_second (" (.+)(\\ .\\ d+)(Z$)" );
810
+ std::smatch m;
811
+ if (std::regex_search (input,m,r_frac_second))
812
+ {
813
+ auto frac = m[2 ].str (); // this is the fractional second
814
+ ufrac_second = timeticks_from_second (frac);
815
+ input = m[1 ].str () + m[3 ].str ();
816
+ }
817
+ #else
818
+ std::regex r_frac_second2 (" (.+)(\\ .\\ d+)(Z$)" );
803
819
// Try to extract the fractional second from the timestamp
804
820
boost::regex r_frac_second (" (.+)(\\ .\\ d+)(Z$)" );
805
821
boost::smatch m;
806
-
807
822
if (boost::regex_search (input,m,r_frac_second))
808
823
{
809
824
auto frac = m[2 ].str (); // this is the fractional second
810
825
ufrac_second = timeticks_from_second (frac);
811
826
input = m[1 ].str () + m[3 ].str ();
812
827
}
828
+ #endif
813
829
814
830
auto result = strptime (input.data (), " %Y-%m-%dT%H:%M:%SZ" , &output);
815
831
@@ -845,7 +861,7 @@ datetime __cdecl datetime::from_string(const utility::string_t& dateString, date
845
861
846
862
struct timeval tv = timeval ();
847
863
tv.tv_sec = time;
848
- tv.tv_usec = (__suseconds_t )ufrac_second;
864
+ tv.tv_usec = (unsigned int )ufrac_second;
849
865
return timeval_to_datetime (tv);
850
866
#endif
851
867
}
0 commit comments