0
我在C++/CLI中有一个变量,它将时间保存为struct tm。我需要将其转换为托管日期时间。我怎样才能做到这一点?如何在C++/cli中将struct tm转换为DateTime
struct tm t=GetTime();
DateTime time= ConvertToDateTime(t);
在上面的代码中,我该如何实现Convert?
我在C++/CLI中有一个变量,它将时间保存为struct tm。我需要将其转换为托管日期时间。我怎样才能做到这一点?如何在C++/cli中将struct tm转换为DateTime
struct tm t=GetTime();
DateTime time= ConvertToDateTime(t);
在上面的代码中,我该如何实现Convert?
一种方法是:
struct tm t = GetTime();
// not sure of syntax here, calling the constructor from C++,
// but I think you get the idea.
DateTime time = DateTime(t.tm_year+1900, t.tm_mon+1, t.tm_day, t.tm_hour, t.tm_min, t.tm_sec);
是。种类也很重要,因为它取决于如何获得,所以对* tm *是不明确的。 –