views:

40

answers:

1

Is it possible to return the current system calendar format using Python? For example non-Gregorian calendar formats such as the Thai Buddhist calendar.

A: 

Under windows?...for this approach you'll need to get the win32api package from here, here's a quick script to read the registry key that holds the default calendar type for the system, but each user has their own key as well, so you may have to dynamically check.

This gets the iCalendarType key value which you find out more about here...

Here's some code to get the value:

import win32api
import win32con

def ReadRegistryValue(hiveKey, key, name=""):

    data = typeId = None
    try:
        keyHandle = win32api.RegOpenKeyEx(hiveKey, key, 0, win32con.KEY_ALL_ACCESS)
        data, typeId = win32api.RegQueryValueEx(keyHandle, name)
        win32api.RegCloseKey(keyHandle)
    except Exception, e:
        print "ReadRegistryValue failed:", hiveKey, key, name, e
    return "Registry Key Value is: " + data


print ReadRegistryValue(win32con.HKEY_USERS,".DEFAULT\\Control Panel\\International","iCalendarType")

Now....what does the value mean other than one(1)? That I couldn't find anywhere, but hopefully this gets you on the right path...

curtisk