How to use the rfc3339.parse_datetime function in rfc3339

To help you get started, we’ve selected a few rfc3339 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atareao / calendar-indicator / src / googlecalendarapi.py View on Github external
def _get_date(self,typeofdate):
        daybefore = datetime.datetime.now(LocalTZ())
        if 'recurrence' in self.keys():
            rset = dateutil.rrule.rruleset()
            for el in self['recurrence']:
                if el.find('DTSTART') == -1:
                    if 'date' in self[typeofdate].keys():
                        dtstart = self[typeofdate]['date']+'T00:00:00'+ get_utc_offset(daybefore)
                        print(self[typeofdate]['date'])
                    elif 'dateTime' in self[typeofdate].keys():
                        dtstart = self[typeofdate]['dateTime']
                        print(self[typeofdate]['dateTime'])
                    print(1,dtstart)
                    dtstart = rfc3339.parse_datetime(dtstart)
                    print(2,dtstart)
                    if el.find('UNTIL') != -1:
                        elements = el.split(';')
                        ans = ''
                        for element in elements:
                            if element.startswith('UNTIL='):
                                s,e=element.split("=")
                                if len(e) == 8:
                                    e += 'T000000'+ get_utc_offset(daybefore).replace(':','')
                                elif len(e) == 17:
                                    e += get_utc_offset(daybefore)
                                element = s+'='+e
                            ans += element+';'
                        if ans.endswith(';'):
                            ans = ans[:-1]
                        el = ans
github langcog / wordbank / common / views.py View on Github external
def format_datetime(date_string):
        dt = rfc3339.parse_datetime(date_string)
        return dt.strftime("%A, %B %d, %Y")
github atareao / calendar-indicator / src / googlecalendarapi.py View on Github external
except Exception as e:
                        print(e)
                try:
                    ans = rset.after(daybefore,inc=True)
                except Exception as e:
                    print(e)
                    ans = None
                if ans is not None:
                    return ans
        if typeofdate in self.keys():
            if 'date' in self[typeofdate].keys():
                dtstart = self[typeofdate]['date']+'T00:00:00'+ get_utc_offset(daybefore)
                return rfc3339.parse_datetime(dtstart)
            elif 'dateTime' in self[typeofdate].keys():
                dtstart = self[typeofdate]['dateTime']
                return rfc3339.parse_datetime(dtstart)
        return None
github atareao / calendar-indicator / src / googlecalendarapi.py View on Github external
try:
                        rrule = dateutil.rrule.rrulestr(el)
                        rset.rrule(rrule)
                    except Exception as e:
                        print(e)
                try:
                    ans = rset.after(daybefore,inc=True)
                except Exception as e:
                    print(e)
                    ans = None
                if ans is not None:
                    return ans
        if typeofdate in self.keys():
            if 'date' in self[typeofdate].keys():
                dtstart = self[typeofdate]['date']+'T00:00:00'+ get_utc_offset(daybefore)
                return rfc3339.parse_datetime(dtstart)
            elif 'dateTime' in self[typeofdate].keys():
                dtstart = self[typeofdate]['dateTime']
                return rfc3339.parse_datetime(dtstart)
        return None
github omarryhan / aiogoogle / aiogoogle / validate.py View on Github external
def datetime_validator(value, schema_name=None):
    msg = make_validation_error_msg(
        value,
        "JSON datetime value. Hint: use datetime.datetime.isoformat(), instead of datetime.datetime",
        schema_name,
    )
    try:
        pvalue = rfc3339.parse_datetime(value)
        # pvalue = datetime.datetime.fromisoformat(value)
    except Exception as e:
        raise ValidationError(str(e), msg)
    if not isinstance(pvalue, datetime.datetime):
        raise ValidationError(msg)

rfc3339

Format dates according to the RFC 3339.

ISC
Latest version published 5 years ago

Package Health Score

49 / 100
Full package analysis