@@ -647,11 +647,13 @@ public virtual ModemResponse SetDateTime(DateTime value)
647647 }
648648
649649 /// <summary>
650- /// Gets the date and time of the modem. Make sure that auto sync is set via <see cref="EnableNetworkDateTimeSync"/> before getting data.
650+ /// Gets the date and time of the modem in UTC format.
651+ /// Make sure that auto sync is set via <see cref="EnableNetworkDateTimeSync"/> before getting data.
651652 /// </summary>
653+ /// <param name="convertToUtc">Should response be converted to UTC. If not it will return local time from modem.</param>
652654 /// <returns>A <see cref="ModemResponse"/> containing the date and time value.
653655 /// If success, Result will contain a <see cref="DateTime"/> class.</returns>
654- public virtual ModemResponse GetDateTime ( )
656+ public virtual ModemResponse GetDateTime ( bool convertToUtc = true )
655657 {
656658 AtResponse response = Channel . SendCommandReadSingleLine ( "AT+CCLK?" , "+CCLK:" ) ;
657659
@@ -671,7 +673,12 @@ public virtual ModemResponse GetDateTime()
671673 int minute = int . Parse ( times [ 1 ] ) ;
672674 int second = int . Parse ( times [ 2 ] . Substring ( 0 , 2 ) ) ;
673675 int zone = int . Parse ( times [ 2 ] . Substring ( 2 , 3 ) ) ;
674- DateTime time = new DateTime ( 2000 + year , month , day , hour , minute , second ) . Add ( TimeSpan . FromMinutes ( 15 * zone ) ) ;
676+ DateTime time = new DateTime ( 2000 + year , month , day , hour , minute , second ) ;
677+ if ( convertToUtc )
678+ {
679+ time = time . Add ( TimeSpan . FromMinutes ( - 15 * zone ) ) ;
680+ }
681+
675682 return ModemResponse . ResultSuccess ( time ) ;
676683 }
677684 }
@@ -764,6 +771,7 @@ public bool WaitForNetworkRegistration(CancellationToken token)
764771 /// <summary>
765772 /// Enables DateTime synchronization from GSM operator.
766773 /// </summary>
774+ /// <returns>A <see cref="ModemResponse"/> indicating the success or failure of the operation.</returns>
767775 public ModemResponse EnableNetworkDateTimeSync ( )
768776 {
769777 var response = Channel . SendCommand ( "AT+CTZU=1" ) ;
0 commit comments