lk-geimfari / mimesis

Mimesis is a robust data generator for Python that can produce a wide range of fake data in multiple languages.
https://mimesis.name
MIT License
4.39k stars 330 forks source link

Datetime timezone support #485

Closed sobolevn closed 5 years ago

sobolevn commented 6 years ago

Currently I am unable to set timezone for cases like this:

processed_at = mimesis('datetime')

But I would like to do something like:

# To select random tz:
processed_at = mimesis('datetime', timezone=True)  # True should be a default, here I am just explicitly calling it

processed_at = mimesis('datetime', timezone=some_specific_tz)

I am not sure about the dependecies. Timezone support out-of-the-box is limited, we almost always use something like pytz.

So, maybe in this case we will just implement the second case. Leaving timezone support optional. And only enabling passed in timezone.

ghost commented 6 years ago

Hi. As I understood it will be a another property zone: Optional[str] = None in constructor of BaseDataProvider. Also one more question: should it be a separate method for getting datetime with timezone or we need to add it to existent?

lk-geimfari commented 6 years ago

@northernwulf Hi! We already have method datetime() and all we need is just add support of parameter timezone for it.

@sobolevn Correct me if I'm wrong.

sobolevn commented 6 years ago

@lk-geimfari it seems correct to me.

ghost commented 6 years ago

@lk-geimfari got it. Thanks

e-vandenberg commented 6 years ago

Hi! Just wondering if this enhancement has been added yet.

If not I'd like to give it a shot.

lk-geimfari commented 6 years ago

@e-vandenberg Hi! It still did not implement you can take it and implement!

e-vandenberg commented 6 years ago

Great. Just so I am not mistaken, would use of this timezone param resemble the following?

>>> d = Datetime()
>>> d.datetime(timezone="America/Guadeloupe")
datetime.datetime(2003, 12, 18, 4, 53, 48, "America/Guadeloupe")

If not, what did you have in mind?

lk-geimfari commented 6 years ago

@sobolevn Please, share with your vision of this feature with @e-vandenberg

sobolevn commented 6 years ago

@e-vandenberg yeap, I had something similar in mind.

lk-geimfari commented 5 years ago

Implemented in #539