ishwi / Chuu

Last.fm bot for discord
MIT License
172 stars 20 forks source link

Timezone formatting unclear #46

Closed katlyn closed 3 years ago

katlyn commented 3 years ago

The help message for setting a user's timezone is as follows:

Name: Timezone Config Description: Sets your timezone so some time functionality of the bot can be more accurate Aliases: !timezone, !tz Usage: !timezone Timezone The timezone can be written either as a abbreviate of the timezone (CET, PT...), the offset of the timezone (+01:00, -12:00...) or trying to write a representative of the timezone using the following format (Europe/Brussels,America/Los Angeles...). Can use --nam to lol

In addition, when a user gives malformed input with the timezone command, this is returned.

Error on katlyn's request: Couldn't parse any timezone from the given message :( The timezone can be written either as a abbreviate of the timezone(CET, PT...),the offset of the timezone (+01:00, -12:00...) or trying to write a representative of the timezone using the following format (Europe/Brussels,America/Los Angeles...) Refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for the full name of the timezones that are accepted.

However, when attempting to set the timezone none of the provided formats are successful. The following commands all returned an error saying the timezone could not be parsed (listen roughly in order of being attempted). !timezone America/Denver !timezone MST (worked but did not return correct timezone) !timezone -07:00 !timezone UTC-07:00 !timezone Australia/Sydney !timezone AEST

In the end, I was able to go through the source code and find out from the test for TimezoneParser that providing the timezone database name without a region (just the city, eg !timezone Denver) would work. After testing, this indeed did work, but without looking through the source code I never would have discovered that using that format would allow the command to complete successfully.

Ideally the parsing should be updated to match the formatting that is given in help messages, though an update to the help message to clarify the formats expected would also be good.

ishwi commented 3 years ago

Hey, first of all thanks for submitting an issue!

Fixed some cases where the parsing was just not working at all. Almost all the cases that you listed in this issue should work. The only one I couldn't parse at all was AEST because the support for abbreviations is a bit flawed.

Now the parsing should remaing consistent with the help/error message. If you detect any error or inconsistency feel free to reopen this issue.