Example #1
0
   def sunrise(self, when=None):
       """
 return the time of sunrise as a datetime.time object
 when is a datetime.datetime object. If none is given
 a local time zone is assumed (including daylight saving
 if present)
 """
       if when is None: when = datetime.now(tz=LocalTimezone())
       self.__preptime(when)
       self.__calc()
       return sun.__timefromdecimalday(self.sunrise_t)
Example #2
0
 def solarnoon(self, when=None, tomorrow=False):
     if when is None:
         when = datetime.now(tz=LocalTimezone())
         if tomorrow:
             when += timedelta(days=1)
     self.__preptime(when)
     self.__calc()
     solarnoon = sun.__timefromdecimalday(self.solarnoon_t)
     if self.return_dates:
         solarnoon = datetime.combine(when, solarnoon)
     return solarnoon
Example #3
0
   def sunrise(self, when=None, tomorrow=False):
       """
 return the time of sunrise as a datetime.time object or datetime.datetime
 object (depending on value of self.return_dates)
 when is a datetime.datetime object. If none is given
 a local time zone is assumed (including daylight saving
 if present)
 tomorrow flag will be used if when is not specified to
 add one complete day to current datetime
 """
       if when is None:
           when = datetime.now(tz=LocalTimezone())
           if tomorrow:
               when += timedelta(days=1)
       self.__preptime(when)
       self.__calc()
       sunrise = sun.__timefromdecimalday(self.sunrise_t)
       if self.return_dates:
           sunrise = datetime.combine(when, sunrise)
       return sunrise
Example #4
0
 def solarnoon(self, when=None):
     if when is None: when = datetime.now(tz=LocalTimezone())
     self.__preptime(when)
     self.__calc()
     return sun.__timefromdecimalday(self.solarnoon_t)
Example #5
0
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from timezone import LocalTimezone
import pytz
from wordcloud import WordCloud, STOPWORDS
import random
from os import path
import nvd3
from markupsafe import Markup

#Google calendar uses RFC3339 datetime standards, so we need to generate those to request
#datetime ranges. The LocalTimezone class handles DST cases
Local = LocalTimezone()


def get_prev_week():
    d = date.today() - timedelta(weeks=1)
    while d.weekday() != 0:
        d = d - timedelta(days=1)
    startTime = datetime.combine(d, datetime.min.time())
    endTime = startTime + timedelta(weeks=1)
    return (startTime.replace(tzinfo=Local).isoformat("T"),
            endTime.replace(tzinfo=Local).isoformat("T"))


def get_last_year():
    endTime = datetime.now(Local)
    startTime = endTime.replace(year=endTime.year - 1)
Example #6
0
 def solarnoon(self, when=None):
     if when is None: when = datetime.now(tz=LocalTimezone())
     self.__preptime(when)
     self.__calc()
     t = Sun.__timefromdecimalday(self.solarnoon_t)
     return when.replace(hour=t.hour, minute=t.minute, second=t.second)