Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 c++/CLI 中有一个变量,它以 struct tm 的形式保存时间。我需要将其转换为托管日期时间。我怎样才能做到这一点?
struct tm t=GetTime(); DateTime time= ConvertToDateTime(t);
在上面的代码中,如何实现转换?
一种方法是:
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);