我现在使用的是Windows::Foundation::DateTime结构,它为我提供的UTC时间值(它的UniversalTime成员)不是UNIX时间戳,我找不到任何关于如何读取它的文档。所以我做了一些测试:
Let
A equal 129862800600000000 where A is UniversalTime's value at 23:00 on 11/7/2012
and let
B equal 129862476000000000 where B is UniversalTime's value at 15:00 on 11/7/2012
We can there for assume that 8 hours of time in whatever format UniversalTime takes can be interpreted as A-B. We therefore have
A-B = 3246000000 = 8 hours
(A-B)/8 = 405750000 = 1 hour
((A-B)/8)/60 = 6762500 = 1 minute
(((A-B)/8)/60)/60 = 112708.(3...) = 1 second事实证明,这是完全错误的。例如,如果您将一个DateTime对象的UniversalTime成员加405750000,它肯定不会增加一个小时。相反,它似乎只增加了40秒。
基本上,我只需要能够确定自unix时代以来已经过去的天数。
无论如何,如果有人有任何建议或帮助,那就太好了。
编辑:我也考虑过他们使用位掩码来获取/设置所有内容的可能性。但目前我不确定该如何去检查它。)现在是凌晨4点,我需要睡觉。rofl)
编辑2:我目前正在尝试做的示例:
if((post_date.UniversalTime/(60*60*24))>num_seconds_since_unix_epoch_for_current_day){
date_formatter=ref new DateTimeFormatter("{month.abbreviated} {day.integer(1)}, {year.full} at {hour.integer(1)}:{minute.integer(2)}:{second.integer(2)}");
}else{
date_formatter=ref new DateTimeFormatter("Today at {hour.integer(1)}:{minute.integer(2)}");
}
date_string = date_formatter->format(post_date);发布于 2012-07-10 00:00:10
Window::Foundation::DateTime的UniversalTime字段是自1601年1月1日以来的100 is单位数。它与Windows的FILETIME结构完全相同。请注意,UniversalTime是协调世界时,它通常与本地时间不同。
发布于 2012-07-09 14:07:07
根据this MS tutorial的说法,您可以使用DateTimeFormatter格式化DateTime。
Windows::Foundation::DateTime dt = (Windows::Foundation::DateTime) value;
Windows::Globalization::DateTimeFormatting::DateTimeFormatter^ dtf =
Windows::Globalization::DateTimeFormatting::DateTimeFormatter::LongDate::get();
dtf->Format(dt);https://stackoverflow.com/questions/11389634
复制相似问题