I have following situation. I have C++ code
1) SystemTimeToFileTime(&st, &m_Time)
Before above call st
is assembled by parsing value from string and assigning to its members manually (please see paragraph about that below) - but only year, month, day, hour, minutes and seconds are assigned to it.
m_Time
is instance variable of type FILETIME.
This method gets called in a function called ToDate
(Here is link to that function for those interested: http://codepad.org/POoiKHMw, I have documented every line of it).
Basically in the end of that method SystemTimeToFileTime
gets called with assembled st
structure being passed to it, I thought I can replicate that manual parsing part in C# easily. That is why I asked only about one function - SystemTimeToFileTime
.
Afterwards there is a function like that:
2) dppDatetime_t RsDateTime::GetAsPrepaidTime() const
{
dppDatetime_t dt;// Just a custom structure, this is no problem to create in C#
SYSTEMTIME st = GetLocalTimeAsSystem();
dt.Year = st.wYear;
dt.Month = st.wMonth;
dt.Day = st.wDay;
dt.Hour = st.wHour;
dt.Minute = st.wMinute;
dt.Second = st.wSecond;
return dt;
}
GetLocalTimeAsSystem
defined as:
3) SYSTEMTIME RsDateTime::GetLocalTimeAsSystem() const
{
SYSTEMTIME st;
::FileTimeToSystemTime(&m_Time, &st);
return st;
}
I basically need to replicate functionality I mentioned in above: 1), 2), 3) points in C#. I would really appreciate some help on how to go with this? How to achieve same result in C#?
User first makes call to 1), then 2) (but 2) calls 3) internally).
Can't I implement what is done above using only DateTime structure in C#?
I am not asking how to do the manual parsing done in ToDate function, I can do that myself too.
EDIT: After comments, here is sample of some input/output:
This is input one can receive in item 1), this string will be parsed and st
structure assembled:
151010070707
Output, what gets written to dppDatetime_t
:
year:2015
month:10
day:10
hour:7
min:7
sec:7
PS These are the format strings I have seen in C++ code the ToDate function is being called with:
//YYMMDDhhmmss - e.g. "151030123030"
//DD.MM.YY
//DD.MM.YYYY - 01.01.2005
//DDMMYYYY