duydao / Text-Pastry

Extend the power of multiple selections in Sublime Text. Modify selections, insert numeric sequences, incremental numbers, generate uuids, date ranges, insert continuously from a word list and more.
MIT License
830 stars 46 forks source link

How to change locale in Windows #94

Closed sergeevabc closed 1 year ago

sergeevabc commented 1 year ago

Dear @duydao, I use your plugin with Sublime 4 on Windows 7 x64. days x7 with a custom date format %Y-%m-%d %A appends weekdays in English. But how do I get weekdays in Russian?

2022-12-05 Monday понедельник 2022-12-06 Tuesday вторник 2022-12-07 Wednesday среда 2022-12-08 Thursday четверг 2022-12-09 Friday пятница 2022-12-10 Saturday суббота 2022-12-11 Sunday воскресенье

duydao commented 1 year ago

Hello @sergeevabc

at the moment, this feature is not supported.

Text Pastry uses strftime for formatting dates. It seems like the only way to change the format is to set the locale, which comes with all kinds of trouble (see https://stackoverflow.com/questions/985505/locale-date-formatting-in-python).

If anyone has an Idea how to achieve this in a safe way, a pull request would be very much appreciated.

Thanks for using Text Pastry!

sergeevabc commented 1 year ago

PowerShell solution (better than nothing). Tested on v5 and v7.

[datetime]$a = Get-Date
[datetime]$b = $a.AddDays(7)
$locale = New-Object System.Globalization.CultureInfo('ru')
0..(($b -$a).Days-1) | % {$a.AddDays($_).ToString('yyyy-MM-dd dddd', $locale)}