2

現在、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を追加した場合、1時間は追加されないことは間違いありません。代わりに、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);
4

2 に答える 2

2

このMSチュートリアルによると、DateTimeFormatterを使用してDateTimeをフォーマットできます。

Windows::Foundation::DateTime dt = (Windows::Foundation::DateTime) value; 
Windows::Globalization::DateTimeFormatting::DateTimeFormatter^ dtf =
    Windows::Globalization::DateTimeFormatting::DateTimeFormatter::LongDate::get();
dtf->Format(dt);
于 2012-07-09T06:07:06.687 に答える
2

Windows :: Foundation :: DateTimeのUniversalTimeフィールドは、1/1/1601以降の100ns単位の数です。これは、WindowsのFILETIME構造とまったく同じです。世界時はUTCであり、現地時間とは異なる場合が多いことに注意してください。

于 2012-07-09T16:00:09.650 に答える