Git Product home page Git Product logo

Comments (6)

fy0 avatar fy0 commented on August 30, 2024

测试了一下发现这种日期会出错:
'2015-01-01 09:09:51.042000+00:00'
这种不会:
'2015-01-01 09:09:51.042000'

但是datetime直接转换就是上面那种,导致任何提到时间的语句基本都会报错,包括last_login等

from uliweb.

limodou avatar limodou commented on August 30, 2024

你可以试一下:

from uliweb.utils import date
print date.now()

看生成的时间是不是带tzinfo的信息。另外检查你是不是设置了TIMEZONE?如在uliweb shell下执行:

>>> print settings.GLOBAL.TIME_ZONE

有没有设置,缺省为None

另外我看你使用了stackless,这个我没有试过,因为生成日期的代码是在uliweb.utils.date中,为:

def now(tzinfo=None):
    tz = pick_timezone(tzinfo, __timezone__)
    return datetime.now(tz)

所以不太确定是不是这块有问题

from uliweb.

fy0 avatar fy0 commented on August 30, 2024

@limodou

确实如此,settings里面加了 TIME_ZONE = 'UTC' 就会出问题。

Uliweb Command Shell

from uliweb.utils import date
print date.now()
2015-01-01 19:42:31.901000

Uliweb Command Shell

from uliweb.utils import date
print date.now()
2015-01-01 11:43:19.638000+00:00

这个是uliwebzone的默认settings
另外问题解决了,多谢

from uliweb.

limodou avatar limodou commented on August 30, 2024

我试了uliwebzone的date.now()结果类似:

datetime.datetime(2015, 1, 1, 13, 11, 33, 381305, tzinfo=<tzinfo UTC>)

而你的tzinfo是空的,不知道为什么。

from uliweb.

fy0 avatar fy0 commented on August 30, 2024

有的,只不过我是print出来了。
若存在 TIME_ZONE = 'UTC',结果如下:

Uliweb Command Shell

from uliweb.utils import date
date.now()
datetime.datetime(2015, 1, 2, 8, 46, 49, 627000, tzinfo=)

若不存在,如下:

Uliweb Command Shell

from uliweb.utils import date
date.now()
datetime.datetime(2015, 1, 2, 16, 46, 19, 467000)

from uliweb.

limodou avatar limodou commented on August 30, 2024

那很奇怪,我这里都是可以的。不过我是mac环境。

from uliweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.