File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,22 @@ public void CreationDate_IsParsed()
9898 torrent . CreationDate . Should ( ) . Be ( new DateTime ( 2016 , 1 , 1 ) ) ;
9999 }
100100
101+ [ Theory ]
102+ [ AutoMockedData ]
103+ public void CreationDate_UnixTimeInMilliseconds_IsParsed ( )
104+ {
105+ // Arrange
106+ ParsedData = ValidSingleFileTorrentData ;
107+ ParsedData [ TorrentFields . CreationDate ] = ( BNumber ) 1451606400000 ;
108+
109+ // Act
110+ var parser = new TorrentParser ( BencodeParser ) ;
111+ var torrent = parser . Parse ( ( BencodeStream ) null ) ;
112+
113+ // Assert
114+ torrent . CreationDate . Should ( ) . Be ( new DateTime ( 2016 , 1 , 1 ) ) ;
115+ }
116+
101117 [ Theory ]
102118 [ InlineAutoMockedData ( "utf8" ) ]
103119 [ InlineAutoMockedData ( "UTF8" ) ]
Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ public static implicit operator bool(BNumber bint)
7272 public static implicit operator DateTime ? ( BNumber number )
7373 {
7474 if ( number == null ) return null ;
75+
76+ if ( number . Value > int . MaxValue )
77+ {
78+ // Assuming unix timestamp is in milliseconds instead of seconds
79+ return Epoch . AddMilliseconds ( number ) ;
80+ }
81+
7582 return Epoch . AddSeconds ( number ) ;
7683 }
7784
You can’t perform that action at this time.
0 commit comments