gpt4 book ai didi

c++ - Windows::Foundation::日期时间

转载 作者:可可西里 更新时间:2023-11-01 11:35:47 25 4
gpt4 key购买 nike

我现在正在使用 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

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

基本上我只需要能够确定自 unix 纪元以来已经过去的天数。

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

编辑:我还考虑过他们使用位掩码来获取/设置所有内容的可能性。但目前我不确定如何着手检查。 (现在是凌晨 4 点,我需要 sleep 。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);

最佳答案

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

关于c++ - Windows::Foundation::日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11389634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com