Paying respect to user culture while consuming user input is totally correct and legal. While hiding the fact of value being parsed with specific user culture may cost a dime.
How expensive that could be?
Make a few predictions to begin with:
- What is the most time-consuming Sitecore hook?
- How much time to get initialized might it take?
- What is the most time-consuming operation in that hook?
Did you predict ~ 3/4 second spent just to transform
00.00:05:00 to TimeSpan?
Sitecore.Configuration.Settings.GetTimeSpanSetting(string name, string defaultValue)would secretly parse
defaultValue using context user culture that is stored in user profile and quite expensive to get on first run:
The neighboring API uses CultureInfo.InvariantCulture for reading config-based value which perfectly makes sense for the task:
Only a few consumers rely on the performance criminal ParseTimeSpan API in 9.3:
Should you need to introduce parse method that pays respect to user culture, please make dependency explicit. Otherwise your intent might be misused with a price tag.
In our example 3/4 seconds of startup time could be saved by:
- Having default value set as
DateUtil.ParseTimeSpanto use context user culture