Giter VIP home page Giter VIP logo

Comments (2)

acaudwell avatar acaudwell commented on August 18, 2024

Thanks for pointing this out and also providing a solution. If it did this and the person has a non English time locale, the text representation of the date would be incorrect? I suppose there is a general solution for this.

from gource.

dionrhys avatar dionrhys commented on August 18, 2024

Here's an example of using strftime with different locales on an online Visual C++ compiler: http://rextester.com/CZTQY99923

Source:

#include <iostream>
#include <ctime>

using namespace std;

int main()
{
    char str[200];
    time_t currTime = time(NULL);
    
    // Default locale
    strftime(str, sizeof(str), "%#x", localtime(&currTime));
    cout << "Default \"C\" Locale (Implicitly-set): " << str << endl; 
    
    // setlocale "C" should also be the Default locale
    setlocale(LC_ALL, "C");
    strftime(str, sizeof(str), "%#x", localtime(&currTime));
    cout << "Default \"C\" Locale (Explicitly-set): " << str << endl; 
    
    // setlocale "" should be the user's system locale
    setlocale(LC_ALL, "");
    strftime(str, sizeof(str), "%#x", localtime(&currTime));
    cout << "User/System Locale: " << str << endl; 
    
    // setlocale "lang-COUNTRY" should set that specific locale
    setlocale(LC_ALL, "es-ES");
    strftime(str, sizeof(str), "%#x", localtime(&currTime));
    cout << "Spanish (Spain) locale: " << str << endl; 
}

Here's the output I get from that site currently:

Default "C" Locale (Implicitly-set): Saturday, April 22, 2017
Default "C" Locale (Explicitly-set): Saturday, April 22, 2017
User/System Locale: Samstag, 22. April 2017
Spanish (Spain) locale: s�bado, 22 22e abril 22e 2017
  (this last line appears to be bugged for some reason, possibly the online compiler is running on a system that's missing some bugfix)

The User/System Locale in the output (3rd line) is from the system that's compiling and running that code, which appears to be German.

So at the moment if the user had a non-English system, Gource would still output time as the default "C" format (the first line in the output), which is based on U.S. English.

I think the default behaviour for Gource should be to use the "" locale so it matches the user's system/profile (and have this set pretty early on when the process starts). There could optionally be a command line option to override the default locale, like --locale "en-GB", with that value passed directly to setlocale (so documentation would need to point out that locales are provided by the system, and different systems have different locale support).

from gource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.