File tree 1 file changed +21
-13
lines changed
1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -10263,24 +10263,32 @@ private:
10263
10263
/+
10264
10264
Returns the given hnsecs as an ISO string of fractional seconds.
10265
10265
+/
10266
- static string fracSecsToISOString (int hnsecs) @safe pure nothrow
10266
+ string fracSecsToISOString (int hnsecs) @safe pure nothrow
10267
10267
{
10268
- assert (hnsecs >= 0 ) ;
10269
-
10268
+ import std.array : appender ;
10269
+ auto w = appender ! string ();
10270
10270
try
10271
- {
10272
- if (hnsecs == 0 )
10273
- return " " ;
10271
+ fracSecsToISOString(w, hnsecs);
10272
+ catch (Exception e)
10273
+ assert (0 , " fracSecsToISOString() threw." );
10274
+ return w.data;
10275
+ }
10274
10276
10275
- string isoString = format(" .%07d" , hnsecs);
10277
+ void fracSecsToISOString (W)(ref W writer, int hnsecs)
10278
+ {
10279
+ import std.conv : toChars;
10280
+ import std.range : padLeft;
10276
10281
10277
- while (isoString[$ - 1 ] == ' 0' )
10278
- isoString.popBack();
10282
+ assert (hnsecs >= 0 );
10279
10283
10280
- return isoString;
10281
- }
10282
- catch (Exception e)
10283
- assert (0 , " format() threw." );
10284
+ if (hnsecs == 0 )
10285
+ return ;
10286
+
10287
+ put(writer, ' .' );
10288
+ auto chars = hnsecs.toChars.padLeft(' 0' , 7 );
10289
+ while (chars.back == ' 0' )
10290
+ chars.popBack();
10291
+ put(writer, chars);
10284
10292
}
10285
10293
10286
10294
@safe unittest
You can’t perform that action at this time.
0 commit comments