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

Weeks does not start with Sunday in Turkish #40

Closed
ghost opened this issue Jan 2, 2024 · 14 comments
Closed

Weeks does not start with Sunday in Turkish #40

ghost opened this issue Jan 2, 2024 · 14 comments

Comments

@ghost
Copy link

ghost commented Jan 2, 2024

In Turkish and some other countries, the first day of the week is Monday (meaning Pazartesi).

GNOME Calendar uses the correct format for this.

Image

On the other hand, Dosage starts the week from Monday.

Week

You may check the following article for more information: https://www.timeanddate.com/calendar/days/

@ghost ghost changed the title Weeks starts with Monday in Turkish Weeks does not start with Monday in Turkish Jan 3, 2024
@ghost ghost changed the title Weeks does not start with Monday in Turkish Weeks does not start with Sunday in Turkish Jan 3, 2024
diegopvlk added a commit that referenced this issue Jan 8, 2024
@diegopvlk
Copy link
Owner

Can you test it?

@ghost
Copy link
Author

ghost commented Jan 8, 2024

Thanks. Fixed.

@ghost ghost closed this as completed Jan 8, 2024
@diegopvlk
Copy link
Owner

Is this still working? When I run with the LC_ALL=tr_TR I still get Sunday as the first day

@ghost
Copy link
Author

ghost commented Jan 29, 2024

Seems broken now.
Ekran Görüntüsü - 2024-01-29 23-01-17

@diegopvlk
Copy link
Owner

Yeah, I have no idea how to reliably get the first day of the week. If you know how, please let me know.

@diegopvlk diegopvlk reopened this Jan 29, 2024
@ghost
Copy link
Author

ghost commented Jan 29, 2024

From Evolution

Ekran Görüntüsü - 2024-01-30 00-24-37

@diegopvlk
Copy link
Owner

diegopvlk commented Jan 29, 2024

I understand very little of this code. The calculation seems to be correct (I think..)

The problem is figuring it out the week number of the current locale (I'm using 1, October 2000) this day for me is on week 40, for you it should be week 39.

It's always gives 40 as the result now, before it gave 39 when I changed the locale, I didn't change anything in the code and somehow it stopped working so ¯_(ツ)_/¯

@ghost
Copy link
Author

ghost commented Jan 31, 2024

Could you use different date. E.g: 1, October 2017. Turkish timezone and daylight saving changed around 2016.

@erklyn
Copy link

erklyn commented Jan 31, 2024

I could try to tackle this.

@diegopvlk
Copy link
Owner

Could you use different date. E.g: 1, October 2017. Turkish timezone and daylight saving changed around 2016.

Doesn't seem to make a difference.

I could try to tackle this.

@erklyn That's the function:

Dosage/src/utils.js

Lines 15 to 24 in 66b505d

function weekStartsMonday() {
const date = new Date(2000, 9, 0);
const startOfYear = new Date(2000, 0, 1);
const dayOfYear = Math.floor((date - startOfYear) / 86400000) + 1;
const weekNumber = Math.ceil(dayOfYear / 7);
// 39 = starts on monday
// 40 = starts on sunday
return weekNumber === 39;
}

If you manage to fix it, please open a PR.

Also make sure to backup your data before running the latest commit, I change some stuff and I didn't test everything properly yet, so it may cause some data loss.

@erklyn
Copy link

erklyn commented Jan 31, 2024

@diegopvlk looks fine and works fine on my system as well, returns 39 for me I am an in Turkey so works correctly.

there might be an issue on the button part. I'll take a look as soon as possible and post a pr.

@diegopvlk
Copy link
Owner

@erklyn It's not the button, you can test it by just returning false instead.

What's your output of locale?

@diegopvlk
Copy link
Owner

Turns out there is a very simple command to check the first weekday: locale first_weekday 🤦‍♂️

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