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

Add option to show US-style date on chart #139

Open
tomshaffner opened this issue Jan 5, 2025 · 4 comments
Open

Add option to show US-style date on chart #139

tomshaffner opened this issue Jan 5, 2025 · 4 comments

Comments

@tomshaffner
Copy link
Contributor

Generated charts always use the non-US style date of day/month/year. This format seems to even be hardcoded in this line:

template_dict["stringTitle"] = f"{self.language_settings['transits']} {self.t_user.day}/{self.t_user.month}/{self.t_user.year}"

Possible to add an option/setting/switch that lets the user decide which date format to use?

@tomshaffner tomshaffner changed the title Show US-style date on chart Add option to show US-style date on chart Jan 5, 2025
@g-battaglia
Copy link
Owner

Hi, yes, it seems like a great idea for an enhancement 😊 However, the best approach would be to set a datetime format string in the config file (kr.config.json) to use in the chart, so everyone can configure their preferred format. What do you think of this idea?

@tomshaffner
Copy link
Contributor Author

tomshaffner commented Jan 6, 2025

Actually, might be useful to have it configurable at runtime somewhere. Otherwise users would need a different instance of the library for different regions. In my case I'd like to be able to automatically switch the format to match the norm for the user, and I will have users both in and outside the US.

@tomshaffner
Copy link
Contributor Author

tomshaffner commented Jan 9, 2025

It might be worth adding babel in here and having the locale be a param? https://babel.pocoo.org/en/latest/ is the library and format could be set like this I think:

from datetime import datetime
from babel.dates import format_date as babel_format_date

def format_date(date: datetime, locale: str = "en_GB") -> str:
    return babel_format_date(date, locale=locale)

If that locale param were passed from calling functions also, with the default set to en_GB, current behavior would be unchanged but easy to alter for the user.

@g-battaglia
Copy link
Owner

From my point of view, it's not the best option—it adds an unnecessary dependency with all that it entails. The best approach might be to pass the desired datetime format string directly within the class fraction, in my opinion.

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

No branches or pull requests

2 participants