-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Implement TimeToDateTime for Symbian #14090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It finally works! Ready to merge... |
I'm not getting the proper time and date. Tried EKA2L1 and on real hardware with similar results.
Not sure (yet) why. |
…sdl-org#14047 libsdl-org#14090 [sdl-ci-filter ngage]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should do the trick:
#define SYMBIAN_UNIX_EPOCH_OFFSET_US 62135596800000000LL
bool SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, bool localTime)
{
CHECK_PARAM(!dt)
{
return SDL_InvalidParamError("dt");
}
long long unixMicros = ticks / 1000LL;
unixMicros += SYMBIAN_UNIX_EPOCH_OFFSET_US;
TInt32 high = (TInt32)(unixMicros >> 32);
TUint32 low = (TUint32)(unixMicros & 0xFFFFFFFFu);
TInt64 symbianTime(high, low);
TTime s60Time(symbianTime);
if (localTime) {
s60Time.HomeTime();
}
TDateTime dtSym = s60Time.DateTime();
dt->year = dtSym.Year();
dt->month = dtSym.Month() + 1; // Months are 0-11
dt->day = dtSym.Day() + 1; // Days are 0-30
dt->hour = dtSym.Hour();
dt->minute = dtSym.Minute();
dt->second = dtSym.Second();
dt->nanosecond = (int)(ticks % 1000000000LL);
dt->day_of_week = s60Time.DayNoInWeek();
dt->utc_offset = 0;
return true;
}
If it's tested enough, can you push that so that we can close this PR and the associated issue ticket? |
I am closing this PR then, you can open one. |
This replaces the stub with a proper implementation
Fixes #14047