You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
Please consider adding support for a Unix Epoch form of Date (unixepoch), as
used by sqlite3. This is very handy for sysadmin-type stuff, and I'm already
using a modified version of the Python library supporting it.
Here is a context diff showing how to implement it:
*** google-visualization-python/gviz_api.py Thu Oct 8 06:00:05 2009
--- with-unixepoch-support/gviz_api.py Mon Oct 18 17:08:11 2010
***************
*** 185,192 ****
Args:
value: The value which should be converted
! value_type: One of "string", "number", "boolean", "date", "datetime" or
! "timeofday".
escape_func: The function to use for escaping strings.
Returns:
--- 185,192 ----
Args:
value: The value which should be converted
! value_type: One of "string", "number", "boolean", "date", "datetime",
! "timeofday" or "unixepoch".
escape_func: The function to use for escaping strings.
Returns:
***************
*** 264,269 ****
--- 264,274 ----
raise DataTableException("Wrong type %s when expected time" % t_value)
return "[%d,%d,%d]" % (value.hour, value.minute, value.second)
+ elif value_type == "unixepoch":
+ if not isinstance(value, (int, long)):
+ raise DataTableException("Wrong type %s when expected seconds since
unix epoch" % t_value)
+ return "new Date(%d)" % (value*1000)
+
elif value_type == "datetime":
if not isinstance(value, datetime.datetime):
raise DataTableException("Wrong type %s when expected datetime" %
***************
*** 335,341 ****
if len(description) > 4:
raise DataTableException("Description error: tuple of length > 4")
if desc_dict["type"] not in ["string", "number", "boolean",
! "date", "datetime", "timeofday"]:
raise DataTableException(
"Description error: unsupported type '%s'" % desc_dict["type"])
return desc_dict
--- 340,346 ----
if len(description) > 4:
raise DataTableException("Description error: tuple of length > 4")
if desc_dict["type"] not in ["string", "number", "boolean",
! "date", "datetime", "timeofday",
"unixepoch"]:
raise DataTableException(
"Description error: unsupported type '%s'" % desc_dict["type"])
return desc_dict
Original issue reported on code.google.com by Warren.H...@gmail.com on 20 Oct 2010 at 2:52
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
Warren.H...@gmail.com
on 20 Oct 2010 at 2:52The text was updated successfully, but these errors were encountered: