def _maybe_cast_slice_bound(self, label, side, kind):
assert kind in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>if isinstance(label, datetime):<EOL><INDENT>return Period(label, freq=self.freq)<EOL><DEDENT>elif isinstance(label, str):<EOL><INDENT>try:<EOL><INDENT>_, parsed, reso = parse_time_string(label, self.freq)<EOL>bounds = self._parsed_string_to_bounds(reso, parsed)<EOL>return bounds[<NUM_LIT:0> if side == '<STR_LIT:left>' else <NUM_LIT:1>]<EOL><DEDENT>except Exception:<EOL><INDENT>raise KeyError(label)<EOL><DEDENT><DEDENT>elif is_integer(label) or is_float(label):<EOL><INDENT>self._invalid_indexer('<STR_LIT>', label)<EOL><DEDENT>return label<EOL>
If label is a string or a datetime, cast it to Period.ordinal according
to resolution.

Parameters
----------
label : object
side : {'left', 'right'}
kind : {'ix', 'loc', 'getitem'}

Returns
-------
bound : Period or object

Notes
-----
Value of `side` parameter should be validated in caller.