首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows::Foundation::DateTime

Windows::Foundation::DateTime
EN

Stack Overflow用户
提问于 2012-07-09 13:48:43
回答 2查看 3.7K关注 0票数 2

我现在使用的是Windows::Foundation::DateTime结构,它为我提供的UTC时间值(它的UniversalTime成员)不是UNIX时间戳,我找不到任何关于如何读取它的文档。所以我做了一些测试:

代码语言:javascript
复制
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:我目前正在尝试做的示例:

代码语言:javascript
复制
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);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-10 00:00:10

Window::Foundation::DateTime的UniversalTime字段是自1601年1月1日以来的100 is单位数。它与Windows的FILETIME结构完全相同。请注意,UniversalTime是协调世界时,它通常与本地时间不同。

票数 2
EN

Stack Overflow用户

发布于 2012-07-09 14:07:07

根据this MS tutorial的说法,您可以使用DateTimeFormatter格式化DateTime。

代码语言:javascript
复制
Windows::Foundation::DateTime dt = (Windows::Foundation::DateTime) value; 
Windows::Globalization::DateTimeFormatting::DateTimeFormatter^ dtf =
    Windows::Globalization::DateTimeFormatting::DateTimeFormatter::LongDate::get();
dtf->Format(dt);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11389634

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档