什么是django.utils.datetime_safe,我应该使用它而不是标准的日期时间吗?

Lor*_*ABA 7 python django datetime

有什么区别?使用更安全datetime_safe吗?我在这个课上找不到任何文件.

sle*_*ica 13

差异在源代码中注明datetime_safe:

# Python's datetime strftime doesn't handle dates before 1900.
# These classes override date and datetime to support the formatting of a date
# through its full "proleptic Gregorian" date range.
Run Code Online (Sandbox Code Playgroud)

呵呵.

  • @Sadra 在 Django4 中未删除,仅已弃用,会引发警告“django.utils.datetime_safe 模块已弃用”。 (3认同)
  • 请注意,`datetime_safe` 将在 [Django 5.0](https://docs.djangoproject.com/en/dev/internals/deprecation/#deprecation-removed-in-5-0) 中删除 (2认同)