Skip to content

Commit f863495

Browse files
temporary incomplete timezone fix
1 parent 26af97a commit f863495

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/mplfinance/plotting.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ def _warn_set_ylim_deprecated(value):
7979
category=DeprecationWarning)
8080
return isinstance(value,bool)
8181

82+
def _tzinfo_dates(dates,tzinfo=None):
83+
if tzinfo != None: # assume 'UTC'; later implement others
84+
return dates
85+
dts = copy.deepcopy(dates)
86+
for ix, d in enumerate(dts):
87+
dts[ix] = d.replace(tzinfo)
88+
return dts
89+
8290

8391
def _valid_plot_kwargs():
8492
'''
@@ -255,7 +263,10 @@ def _valid_plot_kwargs():
255263
'Validator' : lambda value: isinstance(value,mpl_axes.Axes) },
256264

257265
'volume_exponent' : { 'Default' : None,
258-
'Validator' : lambda value: isinstance(value,int) or value == 'legacy'},
266+
'Validator' : lambda value: isinstance(value,int) or value == 'legacy' },
267+
268+
'tzinfo' : { 'Default' : None,
269+
'Validator' : lambda value: isinstance(value,string) },
259270
}
260271

261272
_validate_vkwargs_dict(vkwargs)
@@ -349,9 +360,9 @@ def plot( data, **kwargs ):
349360

350361
if config['show_nontrading']:
351362
formatter = mdates.DateFormatter(fmtstring)
352-
xdates = dates
363+
xdates = _tzinfo_dates(dates,tzinfo=config['tzinfo'])
353364
else:
354-
formatter = IntegerIndexDateTimeFormatter(dates, fmtstring)
365+
formatter = IntegerIndexDateTimeFormatter(_tzinfo_dates(dates,tzinfo=config['tzinfo']),fmtstring)
355366
xdates = np.arange(len(dates))
356367

357368
if external_axes_mode:

0 commit comments

Comments
 (0)