This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/ServiceStack.Text/Support
tests/ServiceStack.Text.Tests/Issues Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public static string ToXsdDuration(TimeSpan timeSpan)
12
12
13
13
sb . Append ( timeSpan . Ticks < 0 ? "-P" : "P" ) ;
14
14
15
- double ticks = Math . Abs ( timeSpan . Ticks ) ;
15
+ double ticks = timeSpan . Ticks > 0 ? timeSpan . Ticks : timeSpan . Ticks * - 1L ;
16
16
double totalSeconds = ticks / TimeSpan . TicksPerSecond ;
17
17
long wholeSeconds = ( long ) totalSeconds ;
18
18
long seconds = wholeSeconds ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using NUnit . Framework ;
3
+
4
+ namespace ServiceStack . Text . Tests . Issues
5
+ {
6
+ public class StackOverflowIssues
7
+ {
8
+ public class MinTypes
9
+ {
10
+ public TimeSpan TimeSpan { get ; set ; }
11
+ }
12
+
13
+ [ Test ]
14
+ public void Can_convert_min_TimeSpan ( )
15
+ {
16
+ var c1 = new MinTypes {
17
+ TimeSpan = TimeSpan . MinValue ,
18
+ } ;
19
+ var json = JsonSerializer . SerializeToString ( c1 , typeof ( MinTypes ) ) ;
20
+ var dto = JsonSerializer . SerializeToString ( c1 , typeof ( MinTypes ) ) ;
21
+ Assert . That ( json , Is . EqualTo ( dto ) ) ;
22
+ }
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments