rosalina: add date and clock in top right corner#2223
rosalina: add date and clock in top right corner#2223MininuxDev wants to merge 9 commits intoLumaTeam:masterfrom
Conversation
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
TuxSH
left a comment
There was a problem hiding this comment.
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:59to 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.
sysmodules/rosalina/source/menu.c
Outdated
| 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I added space padding using a "%23s" format, if this is what you had in mind. Unless you meant manually drawing spaces ?
sysmodules/rosalina/source/menu.c
Outdated
| { | ||
| char buf[32]; | ||
| u64 timeNow = osGetTime(); | ||
| int n = dateTimeToString(buf, timeNow, false); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
sysmodules/rosalina/source/menu.c
Outdated
| @@ -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); | |||
|
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)
|
Does the code honour the time format of the selected region/locale? |
|
No, it only does the 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). |
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. |
Yes. that was my wish. |
- New config.ini option: boolean show_clock_in_rosalina - Add toggle in "Miscellaneous options" submenu
|
I managed to make it optional :) There is now a toggle in the I saw some settings are kept in a single |
|
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.
@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. |
|
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 |
Hi, This PR adds the date and time in the top right corner of rosalina, as suggested in #2185
The time is updated using
osGetTimeon everymenuDraw, ensuring real-time updates. WhenminiSocis enabled, the existing IP address display remains unaffected and the clock is hidden.Tested on n3DS XL