Skip to content

Conversation

eafton
Copy link
Contributor

@eafton eafton commented Sep 30, 2025

This replaces the stub with a proper implementation

Fixes #14047

@eafton
Copy link
Contributor Author

eafton commented Sep 30, 2025

It finally works! Ready to merge...

@sezero sezero requested a review from mupfdev September 30, 2025 22:25
@slouken slouken added this to the 3.4.0 milestone Sep 30, 2025
@mupfdev
Copy link
Collaborator

mupfdev commented Oct 4, 2025

I'm not getting the proper time and date. Tried EKA2L1 and on real hardware with similar results.

1970-02-02 00:00:00.000 (UTC offset: 8 minutes)

Not sure (yet) why.

mupfdev added a commit to mupfdev/SDL that referenced this pull request Oct 4, 2025
Copy link
Collaborator

@mupfdev mupfdev left a 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;
}

@sezero
Copy link
Contributor

sezero commented Oct 4, 2025

This should do the trick:

If it's tested enough, can you push that so that we can close this PR and the associated issue ticket?

@eafton
Copy link
Contributor Author

eafton commented Oct 4, 2025

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;
}

I am closing this PR then, you can open one.

@eafton eafton closed this Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

N-Gage CI build is failing
5 participants