Skip to content

Commit

Permalink
Extract ReadTime from ReadCore
Browse files Browse the repository at this point in the history
References #2
  • Loading branch information
andreashuber-lawo committed Nov 9, 2015
1 parent 944bcc8 commit fe10bc8
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions Lawo.EmberPlusSharp/S101/S101LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,7 @@ private bool ReadCore()
}
else
{
try
{
this.timeUtc = DateTime.ParseExact(
this.logReader.GetAttribute(LogNames.Time),
"HH':'mm':'ss'.'ff",
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
}
catch (ArgumentNullException)
{
this.timeUtc = DateTime.Today;
}
catch (FormatException)
{
this.timeUtc = DateTime.Today;
}

this.timeUtc = this.ReadTime();
this.direction = this.logReader.GetAttribute(LogNames.Direction);
this.number = int.Parse(
this.logReader.GetAttribute(LogNames.Number), NumberStyles.None, CultureInfo.InvariantCulture);
Expand Down Expand Up @@ -203,6 +187,26 @@ private bool ReadCore()
return false;
}

private DateTime ReadTime()
{
try
{
return DateTime.ParseExact(
this.logReader.GetAttribute(LogNames.Time),
"HH':'mm':'ss'.'ff",
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
}
catch (ArgumentNullException)
{
return DateTime.Today;
}
catch (FormatException)
{
return DateTime.Today;
}
}

private byte[] GetLogPayload()
{
byte[] result;
Expand Down

0 comments on commit fe10bc8

Please sign in to comment.