How to use the isodate.datetime_isoformat function in isodate

To help you get started, we’ve selected a few isodate 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 RDFLib / rdflib / test / test_datetime.py View on Github external
def test_timezone_offset_to_utc(self):
        dt = "2010-02-10T12:36:00+03:00"
        l = Literal(dt,
                    datatype=URIRef('http://www.w3.org/2001/XMLSchema#dateTime'))

        utc_dt = l.toPython().astimezone(UTC)
        self.assertEqual(datetime_isoformat(utc_dt),
                         "2010-02-10T09:36:00Z")
github all-of-us / raw-data-repository / rdr_service / lib_fhir / fhirclient_1_0_6 / models / fhirdate.py View on Github external
def isostring(self):
        if self.date is None:
            return None
        if isinstance(self.date, datetime.datetime):
            return isodate.datetime_isoformat(self.date)
        return isodate.date_isoformat(self.date)
github pmlrsg / GISportal / cachescripts / wmsCapabilities.py View on Github external
def genDateRange(startDate, endDate, interval):
   import isodate # https://github.com/gweis/isodate
   
   dates = []
   dateFrom = isodate.parse_datetime(startDate)
   dateTo = isodate.parse_datetime(endDate)
   dateInterval = isodate.parse_duration(interval)
   currentDate = dateFrom
   
   while currentDate <= dateTo:
      datetime = isodate.datetime_isoformat(currentDate)
      dates.append(datetime)
      currentDate = currentDate + dateInterval
      
   return dates
github istSOS / istsos2 / istsoslib / renderers / GCresponseRender.py View on Github external
r += "      \n"
            r += "        " + ofl.desc + "\n"
            r += "        " + ofl.name + "\n"

            if ofl.boundedBy:
                r += "        \n"
                r += "          \n"
                r += "            " + str(ofl.boundedBy) + "\n"
                r += "          \n"
                r += "        \n"

            
            if ofl.beginPosition and ofl.endPosition :
                r += "        <time>\n"
                r += "          \n"
                r += "            " + iso.datetime_isoformat(ofl.beginPosition) + "\n"
                r += "            " + iso.datetime_isoformat(ofl.endPosition) + "\n"
                r += "          \n"
                r += "        </time>\n"
            else:
                r += "        \n"
                
            for pr in ofl.procedures:
                r += "        \n"
            
            for op in ofl.obsProp:
                r += "        \n"
            
            for fo in ofl.fois:
                r += "        \n"
github istSOS / istsos2 / scripts / istsos2csv.py View on Github external
tmpBegin = begin
        tmpEnd = end
        if (end-begin) &gt; step:
            tmpEnd = tmpBegin + step


        while tmpEnd &lt;= end:
            print(("%s - %s") % (tmpBegin, tmpEnd))

            if tmpBegin == tmpEnd:
                params["eventTime"] = iso.datetime_isoformat(tmpBegin)
            else:
                params["eventTime"] = "%s/%s" % (
                    iso.datetime_isoformat(tmpBegin),
                    iso.datetime_isoformat(tmpEnd))

            res = req.get("%s?%s" % (url, urllib.parse.urlencode(params)), auth=auth)

            makeFile(res, procedure, observedProperty, d, qi, filename)
            tmpBegin = tmpEnd
            tmpEnd = tmpBegin + step

            print(" %s ************************** " % iso.datetime_isoformat(
                tmpEnd))

        if tmpBegin &lt; end:
            tmpEnd = end
            if tmpBegin == tmpEnd:
                params["eventTime"] = iso.datetime_isoformat(tmpBegin)
            else:
                params["eventTime"] = "%s/%s" % (
github istSOS / istsos2 / walib / utils.py View on Github external
ON id_off = id_off_fk
        GROUP BY
            id_off, name_off, desc_off, expiration_off, active_off
        ORDER BY
            name_off; """ %((service,)*2)

    rows = pgdb.select(sql,None)
    if rows:
        import isodate
        return [
            {
                "id":row["id"],
                "name":row["name"],
                "description":row["description"],
                "procedures":row["procedures"],
                "expiration": (isodate.datetime_isoformat(row["expiration"])
                    if row["expiration"] else ""),
                "active":row["active"]
            } for row in rows
        ]
    else:
        return []
github istSOS / istsos2 / istSOS / renderers / GCresponseRender.py View on Github external
r += "      \n"
            r += "        " + ofl.desc + "\n"
            r += "        " + ofl.name + "\n"

            if ofl.boundedBy:
                r += "        \n"
                r += "          \n"
                r += "            " + str(ofl.boundedBy) + "\n"
                r += "          \n"
                r += "        \n"

            
            if ofl.beginPosition and ofl.endPosition :
                r += "        <time>\n"
                r += "          \n"
                r += "            " + iso.datetime_isoformat(ofl.beginPosition) + "\n"
                r += "            " + iso.datetime_isoformat(ofl.endPosition) + "\n"
                r += "          \n"
                r += "        </time>\n"
            else:
                r += "        \n"
                
            for pr in ofl.procedures:
                r += "        \n"
            
            for op in ofl.obsProp:
                r += "        \n"
            
            for fo in ofl.fois:
                r += "        \n"
github istSOS / istsos2 / DOCS / SOSutils / render_utils.py View on Github external
fcontent=""
        
        names=["date"]
        dtlis=[]
        for key, tss in self.series.iteritems():
            for id,tsi in enumerate(tss):
                dtlis.append(tsi.tserie)
                names.append(tsi.procedure)
        stack=apply(ts.stack,dtlis)
        dates=stack.dates.tolist()
        
        if mode=="text":
            txt = sep.join(names)
            txt += "\n"
            for l in range(stack.shape[0]):
                txt += "%s" %(iso.datetime_isoformat(dates[l]))
                txt += sosConfig.timezone + sep
                txt += sep.join([str(st) for st in stack.data[l]])
                txt += "\n"
            fcontent += txt

        if fname:
            file = open(fname, 'w')
            file.write(fcontent)
            file.close()
        else:
            return fcontent
github all-of-us / raw-data-repository / rdr_service / lib_fhir / fhirclient_3_0_0 / models / fhirdate.py View on Github external
def isostring(self):
        if self.date is None:
            return None
        if isinstance(self.date, datetime.datetime):
            return isodate.datetime_isoformat(self.date)
        return isodate.date_isoformat(self.date)
github Kegbot / kegbot-server / pykeg / backup / backup.py View on Github external
metadata[META_NUM_MEDIA_FILES] += 1
        for subdir in subdirs:
            add_files(storage, os.path.join((dirname, subdir)), destdir)

    if include_media:
        destdir = os.path.join(backup_dir, 'media')
        for media_dir in MEDIA_WHITELIST:
            if storage.exists(media_dir):
                add_files(storage, media_dir, destdir)
    else:
        logger.warning('Not including media.')

    # Store metadata file.
    metadata[META_SERVER_NAME] = get_title()
    metadata[META_SERVER_VERSION] = get_version()
    metadata[META_CREATED_TIME] = isodate.datetime_isoformat(date)
    metadata[META_DB_ENGINE] = db_impl.engine_name()
    metadata[META_BACKUP_FORMAT] = BACKUP_FORMAT
    metadata_filename = os.path.join(backup_dir, METADATA_FILENAME)
    with open(metadata_filename, 'w') as outfile:
        json.dump(metadata, outfile, sort_keys=True, indent=2)

    valid = False
    try:
        verify_backup_directory(backup_dir)
        valid = True
        return backup_dir
    finally:
        if not valid:
            shutil.rmtree(backup_dir)