locked
How to convert to Calendar object from 1970-elapsed second in C++

    General discussion

  • I obtain 1970-elapsed second for a filetime.
    I want to construct a Calendar object from it. How?

    I tried this:
    Windows::Globalization::Calendar^ WinRTUtils::GetCalenderFrom1970()
    {
    // Considering the daylight savings
    Windows::Globalization::Calendar^ datetime_1970 = ref new Windows::Globalization::Calendar();
    datetime_1970->Year = 1969;
    datetime_1970->Month = 12;
    datetime_1970->Day = 31;
    datetime_1970->Hour = 11;
    datetime_1970->Period = 2;
    datetime_1970->Minute = 0;
    datetime_1970->Second = 0;
    datetime_1970->Nanosecond = 0;
    return datetime_1970;
    }


    Then,

    Windows::Globalization::Calendar^ datetime_value = GetCalenderFrom1970();
    long long value = _atoi64(seconds.c_str());
    datetime_value->AddSeconds(value);

    This initialization is by trial and error to obtain the right result. But it does nto work for dates with AM.
    I tried (1970, 1, 1), that did not work.
    Regards.

    sua

    • Changed type Jesse Jiang Tuesday, February 5, 2013 2:37 AM
    • Changed type Jesse Jiang Tuesday, February 5, 2013 2:37 AM
    Wednesday, January 30, 2013 2:03 AM

All replies

  • Hi,

    Would you please give us the whole codes, and include the right result which you want to get.
     
    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 31, 2013 7:31 AM
  • Hello,

    I would like to change this thread type as discussion, because I think there may be no exact answer for this question.

    Thanks for your understanding,

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 5, 2013 2:37 AM