Package stocks3 :: Package calculators :: Module unixtime
[hide private]
[frames] | no frames]

Source Code for Module stocks3.calculators.unixtime

 1  # -*- coding: utf-8 -*- 
 2   
 3  u""" 
 4  Калькулятор, вычисляющий значение unixtime для котировки. 
 5  """ 
 6   
 7  __author__ = "Zasimov Alexey" 
 8  __email__ = "zasimov-a@yandex-team.ru" 
 9   
10  from stocks3.share.dateandtime import to_unixtime 
11  from stocks3.core.calculator import Calculator 
12  from stocks3.core.factories import calculators 
13  from stocks3.core.default import Default 
14  from stocks3.share.timezone import get_timezone 
15   
16   
17 -class UnixtimeCalculator(Calculator):
18 u""" 19 Добавляет к объекту поле unixtime, содержащее unixtime :) 20 """
21 - def makeConfig(self):
22 self.tz = get_timezone(self)
23 # TODO: сделать проверку корректности временной зоны 24
25 - def calc(self, price):
26 Calculator.calc(self, price) 27 tz = price.tz if price.tz is not None else self.tz 28 unixtime = to_unixtime(price.date, tz) 29 self.saveValue(price, "unixtime", unixtime) 30 return price
31 32 33 calculators.register("stocks3.calculators.Unixtime", UnixtimeCalculator) 34