diff --git a/bot/handlers/editors/date.py b/bot/handlers/editors/date.py index d63ae6e..024e8e6 100644 --- a/bot/handlers/editors/date.py +++ b/bot/handlers/editors/date.py @@ -56,6 +56,12 @@ async def time_picker( if not current_value: current_value = time(0, 0) + else: + remainder = current_value.minute % 5 + if remainder >= 3: + current_value += timedelta(minutes=(5 - remainder)) + else: + current_value -= timedelta(minutes=remainder) for i in range(12): keyboard_builder.row( @@ -173,7 +179,7 @@ async def date_picker( else: start_date = current_value - start_date = current_value.replace(day=1) + start_date = start_date.replace(day=1) previous_month = start_date - timedelta(days=1) next_month = start_date.replace(day=28) + timedelta(days=4) diff --git a/model/bot_entity.py b/model/bot_entity.py index 22ad7cf..51edf19 100644 --- a/model/bot_entity.py +++ b/model/bot_entity.py @@ -86,13 +86,16 @@ class BotEntityMetaclass(SQLModelMetaclass): field_descriptor.is_list = is_list = True field_descriptor.type_base = type_ = get_args(type_)[0] - if type_origin == Union and isinstance(get_args(type_)[0], ForwardRef): - field_descriptor.is_optional = is_optional = True - field_descriptor.type_base = type_ = get_args(type_)[ - 0 - ].__forward_arg__ + if type_origin is Union: + args = get_args(type_) + if isinstance(args[0], ForwardRef): + field_descriptor.is_optional = is_optional = True + field_descriptor.type_base = type_ = args[0].__forward_arg__ + elif args[1] is NoneType: + field_descriptor.is_optional = is_optional = True + field_descriptor.type_base = type_ = args[0] - if type_origin == UnionType and get_args(type_)[1] == NoneType: + if type_origin is UnionType and get_args(type_)[1] is NoneType: field_descriptor.is_optional = is_optional = True field_descriptor.type_base = type_ = get_args(type_)[0]