[1/7] webservices: Strip trailing zeros from time fraction.

Hans Leidekker hans at codeweavers.com
Wed Oct 12 08:30:19 CDT 2016


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/tests/writer.c | 5 ++++-
 dlls/webservices/writer.c       | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index 3bed673..7e65da3 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -2588,6 +2588,8 @@ static void test_datetime(void)
         { 1, WS_DATETIME_FORMAT_UTC, S_OK, "<t>0001-01-01T00:00:00.0000001Z</t>" },
         { 1, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>0001-01-01T00:00:00.0000001+00:00</t>" },
         { 1, WS_DATETIME_FORMAT_NONE, S_OK, "<t>0001-01-01T00:00:00.0000001</t>" },
+        { 10, WS_DATETIME_FORMAT_NONE, S_OK, "<t>0001-01-01T00:00:00.000001</t>" },
+        { 1000000, WS_DATETIME_FORMAT_NONE, S_OK, "<t>0001-01-01T00:00:00.1</t>" },
         { 0x23c34600, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>0001-01-01T00:01:00+00:00</t>" },
         { 0x861c46800, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>0001-01-01T01:00:00+00:00</t>" },
         { 0x430e234000, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>0001-01-01T08:00:00+00:00</t>" },
@@ -2636,7 +2638,8 @@ static void test_datetime(void)
         ok( hr == tests[i].hr, "%u: got %08x\n", i, hr );
         if (hr == S_OK)
         {
-            ok( check_result( writer, tests[i].result ) || broken(check_result( writer, tests[i].result2 )),
+            ok( check_result( writer, tests[i].result ) ||
+                (tests[i].result2 && broken(check_result( writer, tests[i].result2 ))),
                 "%u: wrong result\n", i );
         }
     }
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 619ec2b..36bf65b 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -1235,6 +1235,7 @@ static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
     {
         static const char fmt_frac[] = ".%07u";
         len += sprintf( (char *)buf + len, fmt_frac, sec_frac );
+        while (buf[len - 1] == '0') len--;
     }
     if (ptr->format == WS_DATETIME_FORMAT_UTC)
     {
-- 
2.1.4




More information about the wine-patches mailing list