Beispiel #1
0
    def __init__(self):
        locale.setlocale(locale.LC_CTYPE, "")
        self.window = curses.initscr()
        curses.noecho()
        curses.cbreak()
        self.window.keypad(1)
        self.window.clear()
        self.window.border()

        self.lines, self.cols = self.window.getmaxyx()
        self.day_width = self.cols // 7
        self.day_height = (self.lines - 2) // 6

        self.task_warrior = TaskWarrior(marshal=True)
        pending_tasks = self.task_warrior.load_tasks()['pending']
        self.tasks = {}
        now = datetime.now()
        timezone = LocalTimezone()
        self.offset = timezone.utcoffset(now)
        for task in pending_tasks:
            if 'due' not in task:
                continue
            due = task['due'] + self.offset
            current_date = date(due.year, due.month, due.day)
            if current_date not in self.tasks:
                self.tasks[current_date] = list()
            self.tasks[current_date].append(task)
Beispiel #2
0
    def uploadServerProcess(self):
        self.uploadServerSocket.listen(5)
        while True:
            c, address = self.uploadServerSocket.accept()
            rfcTitle = c.recv(4096).decode().strip()
            if rfcTitle:
                try:
                    stats = os.stat(rfcTitle + '.txt')
                    lastModified = datetime.fromtimestamp(
                        stats.st_mtime).strftime('%a, %d %b %Y %H:%M:%S %Z')
                    reply = ["P2P-CI/1.0 200 OK"]
                    reply.append(
                        "Date:" +
                        datetime.now().strftime('%a,%d %b %Y %H:%M:%S') + " " +
                        LocalTimezone().tzname(datetime.now()))
                    reply.append("OS:" + platform())
                    reply.append("Last-Modified:" + lastModified + " " +
                                 LocalTimezone().tzname(datetime.now()))
                    reply.append("Content-Length:" + str(stats.st_size))
                    reply.append("Content-Type:text/text")
                    c.send("\n".join(reply).encode())

                    with open(rfcTitle + ".txt") as file:
                        for line in file:
                            c.send(line.encode())
                    c.close()
                except:
                    return "P2P-CI/1.0 400 Bad Request"
Beispiel #3
0
    def test_different_timezones(self):
        """ Тестируем две различные таймзоны """
        now = datetime.datetime.now()
        now_tz = datetime.datetime.now(LocalTimezone())
        now_tz_i = datetime.datetime.now(FixedOffset((3 * 60) + 15))

        self.assertEqual(timesince(now), f'0\xa0минут')
        self.assertEqual(timesince(now_tz), "0\xa0минут")
        self.assertEqual(timeuntil(now_tz, now_tz_i), "0\xa0минут")
    def _get_program_ids(self, channel_ids: List[str], days: int,
                         offset: int) -> Generator[int, None, None]:
        start = datetime.combine(
            date.today(), time(0), tzinfo=LocalTimezone()).astimezone(
                self._API_TIMEZONE) + timedelta(days=offset)

        telerama_channel_ids = [
            str(channel_id) for c in channel_ids
            if (channel_id := self._channels.get(c, {}).get("id"))
        ]
Beispiel #5
0
def generate_package_date():
    """
    Reads the system date and time, including the timezone and returns
    a formatted date string suitable for use in the Debian changelog file:

    Example output: Mon, 23 Dec 2013 11:41:00 +1200
    """
    today = datetime.now()
    localtime = LocalTimezone()
    date_with_timezone = today.replace(tzinfo=localtime)
    return date_with_timezone.strftime('%a, %d %b %Y %H:%M:%S %z')
    def _get_xmltv_programs(self, channel_ids: List[str], days: int,
                            offset: int) -> Generator[Element, None, None]:

        start = datetime.combine(
            date.today(), time(0),
            tzinfo=LocalTimezone()) + timedelta(days=offset)
        end = start + timedelta(days=days)

        teleloisirs_channel_ids = [
            str(channel_id) for c in channel_ids
            if (channel_id := self._channels.get(c, {}).get("id"))
        ]
 def validate(self, attrs):
     """Проверки по времени"""
     if attrs['start_meeting_time'] >= attrs['end_meeting_time']:
         raise ValidationError({'end_meeting_time': 'End date should be after start date'})
     if attrs['start_meeting_time'] <= datetime.now(LocalTimezone()):
         raise ValidationError({'start_meeting_time': 'Start date should be after current date'})
     if attrs['end_meeting_time'] - attrs['start_meeting_time'] >= timedelta(days=1):
         raise ValidationError({'end_meeting_time': 'Meeting cannot last more than 1 day'})
     if attrs['start_meeting_time'].time() < START_WORK_OFFICE:
         raise ValidationError({'start_meeting_time': 'Start date should be upper {}'.format(START_WORK_OFFICE)})
     if attrs['end_meeting_time'].time() > END_WORK_OFFICE:
         raise ValidationError({'end_meeting_time': 'End date should be lower {}'.format(END_WORK_OFFICE)})
     return attrs
Beispiel #8
0
        return timedelta(0)

    # end dst()

    def tzname(self, _dt):
        if self.offset == 0:
            return u"UTC"  #$NON-NLS-1$
        return u"TZ:[%2d:%2d]" % (self.offset / 60, self.offset % 60
                                  )  #$NON-NLS-1$

    # end tzname()


# end ZSimpleTimeZone

LOCAL_TIME_ZONE = LocalTimezone()
UTC_TIMEZONE = pytz.utc


# ------------------------------------------------------------------------------
# Getter for the local timezone instance.
# ------------------------------------------------------------------------------
def ZLocalTimezone():
    return LOCAL_TIME_ZONE


# end ZLocalTimezone


# ------------------------------------------------------------------------------
# Setter for the local timezone instance.  This can be used to override the