Windows::Foundation::DateTime



我目前正在使用Windows::Foundation::D ateTime结构,它为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

事实证明这是完全不正确的。 例如,如果将 405750000 添加到 DateTime 对象的 UniversalTime 成员,则它肯定不会为其增加一小时。 相反,它似乎只增加了 40 秒。

基本上,我只需要能够确定自 unix 时代以来经过的天数。

无论如何,如果有人有任何建议或帮助,那就太好了。

编辑:我还考虑过他们使用位掩码来获取/设置所有内容的可能性。 但目前我不确定如何去检查它。 (现在是凌晨4点,我需要睡觉。 罗福尔)

编辑 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);

Windows::Foundation::D ateTime 的 UniversalTime 字段是自 1/1/1601 以来的 100ns 单位数。 它与Windows FILETIME结构完全相同。 请注意,世界时是 UTC,通常与当地时间不同。

根据此 MS 教程,您可以使用 日期时间格式化格式化 日期时间格式化时间格式化格式化时间格式化时间格式化日期时间格式化时间时间格式化日期时间格式化日期时间格式化时间格式化日期时间格式化时间时间

Windows::Foundation::DateTime dt = (Windows::Foundation::DateTime) value; 
Windows::Globalization::DateTimeFormatting::DateTimeFormatter^ dtf =
    Windows::Globalization::DateTimeFormatting::DateTimeFormatter::LongDate::get();
dtf->Format(dt);

最新更新