def set_time_index_from_datetime(self, value, best_fit=True):
steps = self.variable.time_stops<EOL>if value in steps:<EOL><INDENT>self.time_index = steps.index(value)<EOL><DEDENT>elif best_fit:<EOL><INDENT>self.time_index = utils.best_fit(steps, value)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
Sets the time_index parameter from a datetime using start/end/interval/units information from the service
configuration. If best_fit is True, the method will match the closest time index for the given value, otherwise
it will raise a ValueError for any value which doesn't exactly match a time index.