@@ -1372,35 +1372,44 @@ private PdfTrailer ReadXRefStream(PdfCrossReferenceTable xrefTable)
1372
1372
/// <summary>
1373
1373
/// Parses a PDF date string.
1374
1374
/// </summary>
1375
+ /// <remarks>
1376
+ /// Format is
1377
+ /// YYYY Year MM month DD day (01-31) HH hour (00-23) mm minute (00-59) ss second (00.59)
1378
+ /// O is the relationship of local time to Universal Time (UT), denoted by one of the characters +, -, or Z (see below)
1379
+ /// HH followed by ' is the absolute value of the offset from UT in hours (00-23)
1380
+ /// mm followed by ' is the absolute value of the offset from UT in minutes (00-59)
1381
+ /// For example, December 23, 1998, at 7:52 PM, U.S.Pacific Standard Time, is represented by the string,
1382
+ /// D:19981223195200-08'00'
1383
+ /// </remarks>
1384
+
1375
1385
internal static DateTime ParseDateTime ( string date , DateTime errorValue ) // TODO: TryParseDateTime
1376
1386
{
1377
1387
DateTime datetime = errorValue ;
1378
1388
try
1379
1389
{
1380
1390
if ( date . StartsWith ( "D:" ) )
1381
1391
{
1382
- // Format is
1383
1392
// D:YYYYMMDDHHmmSSOHH'mm'
1384
1393
// ^2 ^10 ^16 ^20
1385
1394
int length = date . Length ;
1386
1395
int year = 0 , month = 0 , day = 0 , hour = 0 , minute = 0 , second = 0 , hh = 0 , mm = 0 ;
1387
1396
char o = 'Z' ;
1388
1397
if ( length >= 10 )
1389
1398
{
1390
- year = Int32 . Parse ( date . Substring ( 2 , 4 ) ) ;
1391
- month = Int32 . Parse ( date . Substring ( 6 , 2 ) ) ;
1392
- day = Int32 . Parse ( date . Substring ( 8 , 2 ) ) ;
1399
+ year = int . Parse ( date . Substring ( 2 , 4 ) ) ;
1400
+ month = int . Parse ( date . Substring ( 6 , 2 ) ) ;
1401
+ day = int . Parse ( date . Substring ( 8 , 2 ) ) ;
1393
1402
if ( length >= 16 )
1394
1403
{
1395
- hour = Int32 . Parse ( date . Substring ( 10 , 2 ) ) ;
1396
- minute = Int32 . Parse ( date . Substring ( 12 , 2 ) ) ;
1397
- second = Int32 . Parse ( date . Substring ( 14 , 2 ) ) ;
1404
+ hour = int . Parse ( date . Substring ( 10 , 2 ) ) ;
1405
+ minute = int . Parse ( date . Substring ( 12 , 2 ) ) ;
1406
+ second = int . Parse ( date . Substring ( 14 , 2 ) ) ;
1398
1407
if ( length >= 23 )
1399
1408
{
1400
1409
if ( ( o = date [ 16 ] ) != 'Z' )
1401
1410
{
1402
- hh = Int32 . Parse ( date . Substring ( 17 , 2 ) ) ;
1403
- mm = Int32 . Parse ( date . Substring ( 20 , 2 ) ) ;
1411
+ hh = int . Parse ( date . Substring ( 17 , 2 ) ) ;
1412
+ mm = int . Parse ( date . Substring ( 20 , 2 ) ) ;
1404
1413
}
1405
1414
}
1406
1415
}
@@ -1417,7 +1426,7 @@ internal static DateTime ParseDateTime(string date, DateTime errorValue) // TOD
1417
1426
datetime = datetime . Subtract ( ts ) ;
1418
1427
}
1419
1428
// Now that we converted datetime to UTC, mark it as UTC.
1420
- DateTime . SpecifyKind ( datetime , DateTimeKind . Utc ) ;
1429
+ datetime = DateTime . SpecifyKind ( datetime , DateTimeKind . Utc ) ;
1421
1430
}
1422
1431
else
1423
1432
{
0 commit comments