Skip to content
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

Implement 12hr am-pm style option for time display #5235

Closed
wants to merge 5 commits into from

Conversation

danieljg
Copy link
Contributor

@danieljg danieljg commented Aug 2, 2017

This has been requested in the issue tracker recently (#5216). There doesn't seem to be a way to choose which style will be used for time display using config files. Rgui and xmb have a variable set at compile time to define this.

@danieljg
Copy link
Contributor Author

danieljg commented Aug 2, 2017

As bparker pointed out, this commit relies on gnu extensions to the standard, which wouldn't work in many of the ports. A more portable solution should probably replace this.

@ghost
Copy link

ghost commented Aug 2, 2017

I know we discussed these already, but leaving notes here for others for reference.

It seems some manpages list it as "gnu" and some don't. One I read also states that %p is not guaranteed to even contain a string in all locales. Also not all languages use "PM" nor put their equivalent word after the time. The man page seemed to say it would replace "PM" with the locale-appropriate string, but when I tried this on a Japanese locale machine (Windows 10, tried both mingw and msvc2010), it still used PM when it should have been 午後 (and should be in front of the time)... not sure how we would accommodate that off the top of my head.

This also would need to be a configurable menu setting that does not become the new default.

@gouchi
Copy link
Member

gouchi commented Aug 5, 2017

It seems we need to use wcsftime instead of strftime.

@inactive123
Copy link
Contributor

Did you guys figure out a more portable solution to this yet?

@gouchi
Copy link
Member

gouchi commented Aug 12, 2017

It works with strftime if you called before setlocale(LC_ALL,"")

time

We will have to add datetime.time_mode as an option for rgui and xmb as it is currently hard coded.

@ghost
Copy link

ghost commented Aug 15, 2017

@gouchi It does not work on Linux, I have not tested on Windows yet. And the 午前/午後 must come before the time display. Japanese is not the only language we support that does this either.

@gouchi
Copy link
Member

gouchi commented Aug 15, 2017

It is working with

diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c
index f1ff6b54f..9a2b8e933 100644
--- a/menu/drivers/xmb.c
+++ b/menu/drivers/xmb.c
@@ -2796,7 +2796,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
 
       datetime.s         = timedate;
       datetime.len       = sizeof(timedate);
-      datetime.time_mode = 4;
+      datetime.time_mode = 5;
 
       menu_display_timedate(&datetime);
 
diff --git a/menu/menu_driver.c b/menu/menu_driver.c
index 606a0fcdc..522a8ceef 100644
--- a/menu/menu_driver.c
+++ b/menu/menu_driver.c
@@ -17,6 +17,7 @@
 
 #include <string.h>
 #include <time.h>
+#include <locale.h>
 
 #include <compat/strl.h>
 #include <retro_miscellaneous.h>
@@ -260,6 +261,8 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime)
 
    time(&time_);
 
+   setlocale(LC_ALL,"");
+
    switch (datetime->time_mode)
    {
       case 0: /* Date and time */
@@ -282,6 +285,10 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime)
          strftime(datetime->s, datetime->len,
                "%d/%m %H:%M", localtime(&time_));
          break;
+      case 5: /* Date and time, without year and seconds */
+         strftime(datetime->s, datetime->len,
+             "%c", localtime(&time_));
+         break;
    }
 }

@autofire372
Copy link

Can this get a rebase please?

@gouchi
Copy link
Member

gouchi commented Oct 21, 2017

We will need to add an option for the time display so that we can select which one we want instead of having it hard coded.

@hiddenasbestos
Copy link
Contributor

I'm not sure the recent commit "Introduce button mappings for generic usb controller" belongs in this PR.

@gouchi
Copy link
Member

gouchi commented Oct 7, 2018

@danieljg please close this PR as #7332 has been merged. Thank you.

@danieljg danieljg closed this Oct 8, 2018
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.

None yet

5 participants