How to use the iso8601.tostring function in iso8601

To help you get started, we’ve selected a few iso8601 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 asascience-open / ncWMS / web / WEB-INF / jython / getmetadata.py View on Github external
def _getYearBefore(date):
    """ Returns an ISO8601-formatted date that is exactly one year earlier than
        the given date """
    # Get the tuple of year, month, day etc
    newDate = tuple([date[0] - 1] + list(date[1:]))
    return iso8601.tostring(time.mktime(newDate))
github skarra / ASynK / asynk / contact_gc.py View on Github external
self._snarf_emails_from_gce(gce)
        self._snarf_postal_from_gce(gce)
        self._snarf_org_details_from_gce(gce)
        self._snarf_phones_and_faxes_from_gce(gce)
        self._snarf_dates_from_gce(gce)
        self._snarf_websites_from_gce(gce)
        self._snarf_ims_from_gce(gce)
        self._snarf_sync_tags_from_gce(gce)

        self._snarf_custom_props_from_gce(gce)

        # Google entries do not have a created entry. We should just set it to
        # the current time, and take it from there.
        if not self.get_created():
            self.set_created(iso8601.tostring(time.time()))
            self.set_updated(iso8601.tostring(time.time()))
github asascience-open / ncWMS / web / WEB-INF / jython / capabilities.py View on Github external
output.write(" default=\"%s\">" % vars[vid].zvalues[0])
                    firstTime = 1
                    for z in vars[vid].zvalues:
                        if firstTime:
                            firstTime = 0
                        else:
                            output.write(",")
                        output.write(str(z))
                    output.write("")

                # Set the time dimension
                if len(vars[vid].tvalues) > 0:
                    output.write("" %
                        iso8601.tostring(vars[vid].tvalues[-1]))
                    firstTime = 1
                    for t in vars[vid].tvalues:
                        if firstTime:
                            firstTime = 0
                        else:
                            output.write(",")
                        output.write(iso8601.tostring(t))
                    output.write("")

                output.write("") # end of variable Layer
            output.write("") # end of dataset layer
    
    output.write("") # end of top-level container layer
    
    output.write("")
    output.write("")
github skarra / ASynK / asynk / state.py View on Github external
def set_last_sync_start (self, profile, val=None, sync=True):
        if not val:
            val = iso8601.tostring(time.time())
        return self._set_profile_prop(profile, 'last_sync_start', val, sync)
github skarra / ASynK / asynk / state.py View on Github external
def get_curr_time (self):
        return iso8601.tostring(time.time())
github asascience-open / ncWMS / web / WEB-INF / jython / getfeatureinfo.py View on Github external
# Check for fill values, replacing with "None"
    datavalues = [_checkFillValue(val, _getFillValue()) for val in datavalues]

    req.content_type = info_format

    # Output in simple XML. TODO make this GeoRSS and/or KML?
    if info_format == "text/xml":
        req.write("\n")
        req.write("")
        req.write("%f" % lon)
        req.write("%f" % lat)
        for i in xrange(len(tIndices)):
            req.write("")
            if len(var.tvalues) > 0:
                tval = var.tvalues[tIndices[i]]
                req.write("<time>%s</time>" % iso8601.tostring(tval))
            if datavalues[i] is None:
                req.write("none") 
            else:
                req.write("%s" % str(datavalues[i]))
            req.write("")
        req.write("")
    else:
        # Output the data as a PNG JFreeChart (most useful for timeseries)
        # TODO: this needs to be separated to preserve pure Python
        ts = TimeSeries("Data", Millisecond)
        for i in xrange(len(tIndices)):
            tval = var.tvalues[tIndices[i]]
            tvalLong = Double(tval * 1000).longValue()
            date = Date(tvalLong)
            ts.add(Millisecond(date), datavalues[i])
        xydataset = TimeSeriesCollection()
github asascience-open / ncWMS / web / WEB-INF / jython / getmetadata.py View on Github external
doc.write("")
    datasets = config.datasets
    for ds in datasets.keys():
        if datasets[ds].ready:
            doc.write("%s" % datasets[ds].title)
            vars = datasets[ds].variables
            for format in getmap.getSupportedImageFormats():
                doc.write("")
                for varID in vars.keys():
                    doc.write("<a in="" for="" href="\&quot;%s?SERVICE=WMS&amp;REQUEST=GetMap&amp;VERSION=1.3.0&amp;STYLES=&amp;CRS=CRS:84&amp;WIDTH=256&amp;HEIGHT=256&amp;FORMAT=%s&amp;TRANSPARENT=true&quot;"> 0:
                        doc.write("&amp;TIME=%s" % iso8601.tostring(tvals[-1]))
                    doc.write("\"&gt;%s</a><br>" % vars[varID].title)
                doc.write("")
            if config.server.allowFeatureInfo:
                doc.write("")
                if datasets[ds].queryable:
                    for varID in vars.keys():
                        doc.write("<a in="" for="" href="\&quot;%s?SERVICE=WMS&amp;REQUEST=GetFeatureInfo&amp;VERSION=1.3.0&amp;CRS=CRS:84&amp;WIDTH=256&amp;HEIGHT=256&amp;INFO_FORMAT=text/xml&quot;"> 0:
                            doc.write("&amp;TIME=%s" % iso8601.tostring(tvals[-1]))
                        doc.write("\"&gt;%s</a><br>" % vars[varID].title)
                else:
github asascience-open / ncWMS / web / WEB-INF / jython / getmetadata.py View on Github external
def _getMonthAfter(date):
    """ Returns an ISO8601-formatted date that is exactly one month later than
        the given date """
    if date[1] == 12:
        month = 1
        year = date[0] + 1
    else:
        month = date[1] + 1
        year = date[0]
    newDate = tuple([year] + [month] + list(date[2:]))
    return iso8601.tostring(time.mktime(newDate))
github skarra / ASynK / asynk / contact_gc.py View on Github external
self._snarf_group_membership_from_gce(gce)
        self._snarf_emails_from_gce(gce)
        self._snarf_postal_from_gce(gce)
        self._snarf_org_details_from_gce(gce)
        self._snarf_phones_and_faxes_from_gce(gce)
        self._snarf_dates_from_gce(gce)
        self._snarf_websites_from_gce(gce)
        self._snarf_ims_from_gce(gce)
        self._snarf_sync_tags_from_gce(gce)

        self._snarf_custom_props_from_gce(gce)

        # Google entries do not have a created entry. We should just set it to
        # the current time, and take it from there.
        if not self.get_created():
            self.set_created(iso8601.tostring(time.time()))
            self.set_updated(iso8601.tostring(time.time()))