Not excited about NETMF yet? here is another one for you!
http://blogs.msdn.com/b/netmfteam/archive/2011/08/18/netmf-4-2-regular-expressions.aspx
Yes yes we know, you want NETMF4.2 and we are working on it No we do not have a set date yet.
Not excited about NETMF yet? here is another one for you!
http://blogs.msdn.com/b/netmfteam/archive/2011/08/18/netmf-4-2-regular-expressions.aspx
Yes yes we know, you want NETMF4.2 and we are working on it No we do not have a set date yet.
Until Regex arrives…
Is there a simpler was to do sscanf()?
I need to convert a time date string to a DateTime variable
I have a hand crafted bit of code to strip out substrings and convert to int’;s etc ,
BUT
Is there a more elegant way?
What about:
DateTime dt = new DateTime(int year, int month, int day, int hour, int minute, in second);
I’m actually after the other way round:
DateTime dt = sscanf("23/11/2011 20:28:33.982");
Instead of a one line .NET Framework call to
Convert.ToDateTime( "" )
.NET Micro Framework doesn’t support this so need to do something like:
public static class _DateTimec
{
public static DateTime ToDateTime(string sDT)
{
DateTime T = DateTime.MinValue;
try
{
int d, m, y, H, M, S, F;
int pS, pE;
//INT'L Format
//Format: "27/12/1969 15:41:30.789" or "1/1/2011 1:41:30"
pS = 0;
pE = sDT.IndexOf(@ "/");
d = Convert.ToInt32(sDT.Substring(pS, pE - pS));
pS = pE + 1;
pE = sDT.IndexOf("/", pS);
m = Convert.ToInt32(sDT.Substring(pS, pE - pS));
pS = pE + 1;
pE = sDT.IndexOf(" ", pS);
y = Convert.ToInt32(sDT.Substring(pS, pE - pS));
if (y < 2000)
{
y = y + 2000;
}
pS = pE + 1;
pE = sDT.IndexOf(":", pS);
H = Convert.ToInt32(sDT.Substring(pS, pE - pS));
pS = pE + 1;
pE = sDT.IndexOf(":", pS);
M = Convert.ToInt32(sDT.Substring(pS, pE - pS));
pS = pE + 1;
pE = sDT.IndexOf(".", pS);
if (pE > -1)
{
S = Convert.ToInt32(sDT.Substring(pS, pE - pS));
pS = pE + 1;
pE = sDT.Length;
F = Convert.ToInt32(sDT.Substring(pS, pE - pS));
}
else
{
S = Convert.ToInt32(sDT.Substring(pS, sDT.Length - pS));
F = 0;
}
T = new DateTime(y, m, d, H, M, S, F);
}
catch(Exception)
{
T = DateTime.MinValue;
}
// In absence of Convert.ToDateTime or
// DateTime dt2 = DateTime.Parse(date, culture, System.Globalization.DateTimeStyles.AssumeLocal);
return T;
}
}
That would make a nice DateTime.Parse() extension method since that’s basically what you’ve built.