python datetime에서 hour 문제
조회수 1532회
질문이 길어질 것 같지는 않습니다.
정확히 말하면 python django에서 model에 시간을 24:00:00으로 저장해야 하는데, 24:00:00으로 입력을 하면
Time has wrong format. Use one of these formats instead: hh:mm[:ss[.uuuuuu]].
라는 오류를 반환하길래 datetime에서도 직접 테스트 해보니
>>> a = datetime.datetime(2018, 1, 11, 24, 0, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: hour must be in 0..23
hour 범위가 0~23이더군요. 혹시 0시와 24시를 구분해야 하는데, 방법 없을까요?
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
https://bugs.python.org/issue10427
상기의 버그트래킹을 참고해보세요.
결론만 이야기 하면
datetime(Y, M, D) + timedelta(1)
와 같이 델타값을 임의로 줘서 판단하라고 하네요.
댓글 입력