~ubuntu-branches/ubuntu/trusty/pycalendar/trusty

« back to all changes in this revision

Viewing changes to src/pycalendar/manager.py

  • Committer: Package Import Robot
  • Author(s): Rahul Amaram
  • Date: 2012-05-29 12:42:34 UTC
  • Revision ID: package-import@ubuntu.com-20120529124234-mzwu4vw4chh0sc1f
Tags: upstream-2.0~svn188
ImportĀ upstreamĀ versionĀ 2.0~svn188

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##
 
2
#    Copyright (c) 2007-2011 Cyrus Daboo. All rights reserved.
 
3
#    
 
4
#    Licensed under the Apache License, Version 2.0 (the "License");
 
5
#    you may not use this file except in compliance with the License.
 
6
#    You may obtain a copy of the License at
 
7
#    
 
8
#        http://www.apache.org/licenses/LICENSE-2.0
 
9
#    
 
10
#    Unless required by applicable law or agreed to in writing, software
 
11
#    distributed under the License is distributed on an "AS IS" BASIS,
 
12
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
#    See the License for the specific language governing permissions and
 
14
#    limitations under the License.
 
15
##
 
16
 
 
17
from pycalendar.timezone import PyCalendarTimezone
 
18
 
 
19
class PyCalendarManager(object):
 
20
 
 
21
    sICalendarManager = None
 
22
 
 
23
    def __init__(self):
 
24
        self.mDefaultTimezone = PyCalendarTimezone()
 
25
 
 
26
    def initManager(self):
 
27
        # TODO: - read in timezones from vtimezones.ics file
 
28
 
 
29
        # Eventually we need to read these from prefs - for now they are
 
30
        # hard-coded to my personal prefs!
 
31
        self.setDefaultTimezone(PyCalendarTimezone(utc=False, tzid="US/Eastern"))
 
32
 
 
33
    def setDefaultTimezoneID(self, tzid):
 
34
        # Check for UTC
 
35
        if tzid == "UTC":
 
36
            temp = PyCalendarTimezone(utc=True)
 
37
            self.setDefaultTimezone(temp)
 
38
        else:
 
39
            temp = PyCalendarTimezone(utc=False, tzid=tzid)
 
40
            self.setDefaultTimezone(temp)
 
41
 
 
42
    def setDefaultTimezone(self, tzid):
 
43
        self.mDefaultTimezone = tzid
 
44
 
 
45
    def getDefaultTimezoneID(self):
 
46
        if self.mDefaultTimezone.getUTC():
 
47
            return "UTC"
 
48
        else:
 
49
            return self.mDefaultTimezone.getTimezoneID()
 
50
 
 
51
    def getDefaultTimezone(self):
 
52
        return self.mDefaultTimezone
 
53
 
 
54
PyCalendarManager.sICalendarManager = PyCalendarManager()