Skip to content

rosalina: add date and clock in top right corner#2223

Open
MininuxDev wants to merge 9 commits intoLumaTeam:masterfrom
MininuxDev:add_clock
Open

rosalina: add date and clock in top right corner#2223
MininuxDev wants to merge 9 commits intoLumaTeam:masterfrom
MininuxDev:add_clock

Conversation

@MininuxDev
Copy link
Copy Markdown

Hi, This PR adds the date and time in the top right corner of rosalina, as suggested in #2185

The time is updated using osGetTime on every menuDraw, ensuring real-time updates. When miniSoc is enabled, the existing IP address display remains unaffected and the clock is hidden.

Tested on n3DS XL

screenshot

The time is updated using osGetTime on every menuDraw, ensuring real-time updates.

When miniSoc is enabled, the existing IP address display remains unaffected and the clock is hidden.
Copilot AI review requested due to automatic review settings March 1, 2026 21:42

This comment was marked as duplicate.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@TuxSH TuxSH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for taking your time to contribute.

In principle okay, but not what I had in mind:

  • I want this format: Wed, 31 Dec 2025 23:59 to be used
  • Ensure space padding (the framebuffer isn't always cleared)

I understand that this is more difficult to implement. I'm fairly busy this semester and neglected this repo, but this was already on my list of things I want to do before next release.

Additionally, could you please not use Copilot in the PR interface (and instead use it offline before committing) nor as a co-author? Microsoft does not offer any way to prevent this on this repo; please ensure Automatic Copilot code review is disabled in your account settings.

This clutters review (making my job harder) and, generally speaking, maintainers of other repositories will be less kind about it.

char buf[32];
u64 timeNow = osGetTime();
int n = dateTimeToString(buf, timeNow, false);
Draw_DrawString(SCREEN_BOT_WIDTH - 10 - SPACING_X * n, 10, COLOR_WHITE, buf);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you ensure both the date string and the IP string are the same length, padding them with spaces as necessary? They aren't always cleared automatically.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added space padding using a "%23s" format, if this is what you had in mind. Unless you meant manually drawing spaces ?

{
char buf[32];
u64 timeNow = osGetTime();
int n = dateTimeToString(buf, timeNow, false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using the ISO format used for screenshots, could you use this format: Wed, 31 Dec 2025 23:59. It is more readable and match what I'm using in a side project I'll soon integrate into Luma3DS.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the dateTimeToString function to accept an enum parameter dateTimeFormat to select the format, including the human readable format (and thus adjusted the calls to the function in other places)

I could move the human readable formatter to another function if necessary.

@@ -475,9 +475,13 @@ static void menuDraw(Menu *menu, u32 selected)
int n = sprintf(ipBuffer, "%hhu.%hhu.%hhu.%hhu", addr[0], addr[1], addr[2], addr[3]);
Draw_DrawString(SCREEN_BOT_WIDTH - 10 - SPACING_X * n, 10, COLOR_WHITE, ipBuffer);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below

@MininuxDev
Copy link
Copy Markdown
Author

MininuxDev commented Mar 1, 2026

Oops, sorry about the copilot thingy, and thanks for the heads up. Never would have thought it would get enabled everywhere by default...

edit: I just noticed that copilot added itself as a co-author on the commit that removes the unnecessary include. If that's problematic enough to warrant a force push, feel free to let me know and I can remove it.

Add an enum DateTimeFormat to select a format to be used by dateTimeToString,
between ISO, format used by filenames, and human readable (used by the clock)
@eku
Copy link
Copy Markdown

eku commented Mar 2, 2026

Does the code honour the time format of the selected region/locale?

@MininuxDev
Copy link
Copy Markdown
Author

No, it only does the %a, %d %b %Y %H:%M format.

I could take inspiration from https://github.com/libsdl-org/SDL/blob/main/src/time/n3ds/SDL_systime.c to make the format adapt to the locale (code is under z-lib license).

@eku
Copy link
Copy Markdown

eku commented Mar 2, 2026

No, it only does the %a, %d %b %Y %H:%M format.

Then, please make it optional.

@MininuxDev
Copy link
Copy Markdown
Author

Then, please make it optional.

Do you mean the clock should be toggleable in the settings ? It could be done, I'll have to see how to get and set settings.

Or do you mean the formatting should be optional ? In that case, considering the language itself won't be adjusted to the locale settings, I'm not sure if it's worth it, except maybe a 12H/24H format switch.

@eku
Copy link
Copy Markdown

eku commented Mar 4, 2026

Then, please make it optional.

Do you mean the clock should be toggleable in the settings ?

Yes. that was my wish.

- New config.ini option: boolean show_clock_in_rosalina
- Add toggle in "Miscellaneous options" submenu
@MininuxDev
Copy link
Copy Markdown
Author

I managed to make it optional :) There is now a toggle in the Miscellaneous options submenu in rosalina, and a matching option in the config.ini file.

I saw some settings are kept in a single u32 field in the CfgData and CfwInfo structs (config, multiConfig and bootConfig), while other are separate. Considering the clock is a setting that only concerns rosalina and not the patches/other sysmodules, I chose to add a new field showClockInRosalina to these structs. If this is not the right thing to do, I could move it in the CfgData.config field instead.

@TuxSH
Copy link
Copy Markdown
Member

TuxSH commented Mar 19, 2026

I don't think making optional is a good idea. The previous behavior was fine.

Localization/translation is something that, barring a few exceptions, will not be done for this project for various technical reasons.

Then, please make it optional.

@eku While I understand you were trying to give constructive advice, I would prefer if you didn't phrase it in a way that could be misinterpreted (by less experienced people) as you being a maintainer, which is not the case.

@MininuxDev
Copy link
Copy Markdown
Author

MininuxDev commented Mar 22, 2026

Ok I can revert the commits that make it optional then, it makes sense if the rest of luma is not localized.

By the way I also stumbled upon this algorithm https://howardhinnant.github.io/date_algorithms.html#civil_from_days to compute the number of days and time without doing a while loop on every year since 1900 on every refresh, although the current implementation works fine.

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.

4 participants