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)
1212
1313 sb . Append ( timeSpan . Ticks < 0 ? "-P" : "P" ) ;
1414
15- double ticks = Math . Abs ( timeSpan . Ticks ) ;
15+ double ticks = timeSpan . Ticks > 0 ? timeSpan . Ticks : timeSpan . Ticks * - 1L ;
1616 double totalSeconds = ticks / TimeSpan . TicksPerSecond ;
1717 long wholeSeconds = ( long ) totalSeconds ;
1818 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