Search code examples
windowsglobalization

Determine regional business days and weekend days of the week


In some countries weekend days are Friday/Saturday.

How can a Windows application find out weekend days of the user?


Solution

  • Wellll...I don't know of a "One function" answer to this. You're gonna need to know where they are somehow. If it's a webapp, you can trace their IP and figure out what country they are from. If it's a windows app, you're probably going to need to ask them (The clock only provides timezone information, and i can't figure out where else to grab a more fine-grained location from windows).

    You can figure out what day it is with GetDayofWeek http://msdn.microsoft.com/en-us/library/1wzak8d0%28VS.80%29.aspx in MFC

    DayofWeek if you hop to .Net http://msdn.microsoft.com/en-us/library/system.dayofweek.aspx

    You'll need a lookup table with countries/what days they consider weekends..you'll probably have to construct this, but you can get a list of countries from: http://www.iso.org/iso/english_country_names_and_code_elements

    That list is ISO 3166.

    It's updated and should be your "one-stop-shop" for the listing. From there, you'll match "weekends" to the countries. http://en.wikipedia.org/wiki/Workweek might help in figuring out weekends/workweeks for countries.