Skip to content

Commit

Permalink
Used Dimension.type_formatters to format datetime if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Apr 17, 2016
1 parent 81b0191 commit a822871
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion holocube/element/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
from holoviews.core.dimension import Dimension
from holoviews.core.util import * # noqa (API import)

import datetime

def get_date_format(coord):
def date_formatter(val, pos=None):
return coord.units.num2date(val)
date = coord.units.num2date(val)
date_format = Dimension.type_formatters.get(datetime.datetime, None)
if date_format:
return date.strftime(date_format)
else:
return date

return date_formatter

def coord_to_dimension(coord):
Expand Down

0 comments on commit a822871

Please sign in to comment.