Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
osrtc.py
Go to the documentation of this file.
1 # Copyright 2014 Andreas Riegg - t-h-i-n-x.net
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # Changelog
16 #
17 # 1.0 2014-09-02 Initial release.
18 #
19 # Usage remarks
20 #
21 # - The driver just uses the system clock as available within standard
22 # Python. As standard Python does not support setting the system time,
23 # this functionality is not available.
24 #
25 # Implementation remarks
26 #
27 # - All __set... methods are not reimplemented, so calling them will lead
28 # to the intended NotImplementedError. Dow uses ISO format (1..7).
29 
30 
31 from webiopi.devices.clock import Clock
32 from datetime import datetime
33 
34 
35 class OsClock(Clock):
36 
37 #---------- Class initialisation ----------
38 
39  def __init__(self):
40  Clock.__init__(self)
41 
42 
43 #---------- Abstraction framework contracts ----------
44 
45  def __str__(self):
46  return "OsClock"
47 
48  def close(self):
49  return
50 
51 
52 #---------- Clock abstraction related methods ----------
53 
54  def __getSec__(self):
55  return (datetime.now()).second
56 
57  def __getMin__(self):
58  return (datetime.now()).minute
59 
60  def __getHrs__(self):
61  return (datetime.now()).hour
62 
63  def __getDay__(self):
64  return (datetime.now()).day
65 
66  def __getMon__(self):
67  return (datetime.now()).month
68 
69  def __getYrs__(self):
70  return (datetime.now()).year
71 
72  def __getDow__(self):
73  return (datetime.now()).isoweekday()
74 
75 
76 #---------- Clock default re-implementations ----------
77 
78  def __getDateTime__(self):
79  return datetime.now()
80 
81  def __getDate__(self):
82  return (datetime.now()).date()
83 
84  def __getTime__(self):
85  return (datetime.now()).time()
86 
87