Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompelete timetuple. #34

Open
Mahyar24 opened this issue Apr 6, 2020 · 0 comments
Open

incompelete timetuple. #34

Mahyar24 opened this issue Apr 6, 2020 · 0 comments
Labels

Comments

@Mahyar24
Copy link

Mahyar24 commented Apr 6, 2020

the default datetime module return timetuple with hour, minute, and second but what JalaliDatetime.timetuple() returns doesn't have these three items, so sadly in my case I should make my timetuple manually, I know that it's not a big deal but I think maybe it's the best that your excellent library behaves just like datetime.
for my use, I need to have timetuple with date and time of Tehran timezone on a foreign server for logging my logs into our Persian paradigm. (if it's help!)

from khayyam import JalaliDatetime
from time import struct_time
from pytz import timezone

def tehrantime(*args, **kwargs):
    tehran_dt = JalaliDatetime.now(tz=timezone('Asia/Tehran'))
    time_tuple = struct_time((tehran_dt.year, tehran_dt.month, tehran_dt.day, tehran_dt.hour, tehran_dt.minute, 
                              tehran_dt.second, tehran_dt.weekday(), tehran_dt.dayofyear(), 1))
    return time_tuple

Thanks BTW.

@pylover pylover added the bug label Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants