예제 #1
0
    def _get_todays_records(self, day_offset=0):
        # get today
        today = datetime.datetime.now()
        # apply offset
        today = today + datetime.timedelta(days=day_offset)

        # drop everything smaller than day and for some reason
        # today.replace(hour=0, minute=0, second=0, microsecond=0)
        # was not working at all. so this is my work around
        day = datetime.datetime(today.year, today.month, today.day)

        # make time deltas for some UTC math
        # central time is 6 hours before utc
        td_hours = datetime.timedelta(hours=6)
        td_day = datetime.timedelta(days=1)
        date_min = day + td_hours

        date_max = date_min + td_day
        return TimeSheet.select().where(
            TimeSheet.time_in <= date_max, TimeSheet.time_in >= date_min)
예제 #2
0
 def _get_newest():
     try:
         return TimeSheet.select().order_by(TimeSheet.id.desc())[0].id
     except Exception:
         pass