emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Expose now_local #185

Closed Marlysson closed 7 years ago

Marlysson commented 7 years ago

What you think about expose the now_local method from Request object as line now method to use the local timezone and not UTC ..

gi0baro commented 7 years ago

@Marlysson I think is useless as weppy now uses pendulum for the now object, so if you need to always use a specific timezone you can just write a 1 line method for that:

from weppy import now

def local_now():
    return now().in_timezone("Europe/Berlin")
Marlysson commented 7 years ago

Hmm .. It's because the Request object have the now method that is expose at end of file.. and too have the method local_now ..

But then import the now method ( that is expose in globals file ) and overwrite it with behavior that I want.

gi0baro commented 7 years ago

Caution: now it's not necessarily request.now. The now function defined in globals it's not just an exposure of the request method. It's evaluated dependently on the context. The fact request has a local_now it's just for a backward compatibility reference.