Last active
November 15, 2016 09:40
-
-
Save RemiBou/82c7b5a7847ffb79a9459a2ced6f9b4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Record | |
{ | |
public DateTime Start; | |
public DateTime End; | |
public long Id; | |
public TimeSpan Duration => End - Start; | |
private static long[] _pows = Enumerable.Range(0, 8).Select(i => (long)Math.Pow(10, i)).ToArray(); | |
public Record(string line) | |
{ | |
Start = new DateTime( | |
(int) (Char.GetNumericValue(line[0])*1000+ Char.GetNumericValue(line[1])*100+ Char.GetNumericValue(line[2])*10+ Char.GetNumericValue(line[3])), | |
(int)(Char.GetNumericValue(line[5]) * 10 + Char.GetNumericValue(line[6])), | |
(int)(Char.GetNumericValue(line[8]) * 10 + Char.GetNumericValue(line[9])), | |
(int)(Char.GetNumericValue(line[11]) * 10 + Char.GetNumericValue(line[12])), | |
(int)(Char.GetNumericValue(line[14]) * 10 + Char.GetNumericValue(line[15])), | |
(int)(Char.GetNumericValue(line[17]) * 10 + Char.GetNumericValue(line[18]))); | |
const int dateEndStartChar = 20; | |
End = new DateTime( | |
(int)(Char.GetNumericValue(line[0+dateEndStartChar]) * 1000 + Char.GetNumericValue(line[1 + dateEndStartChar]) * 100 + Char.GetNumericValue(line[2 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[3 + dateEndStartChar])), | |
(int)(Char.GetNumericValue(line[5 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[6 + dateEndStartChar])), | |
(int)(Char.GetNumericValue(line[8 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[9 + dateEndStartChar])), | |
(int)(Char.GetNumericValue(line[11 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[12 + dateEndStartChar])), | |
(int)(Char.GetNumericValue(line[14 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[15 + dateEndStartChar])), | |
(int)(Char.GetNumericValue(line[17 + dateEndStartChar]) * 10 + Char.GetNumericValue(line[18 + dateEndStartChar]))); | |
for (int i = 7; i >= 0; i--) | |
{ | |
Id += (long)(char.GetNumericValue(line[i+40])* _pows[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment