iranian datetime package

Updated fonzali 0 Tallied Votes 518 Views Share

@Niloofar24 was looking for an Iranian datetime package and last night I found one in the internet so I wrote a simple code which counts the days and hours and seconds to Iranian new year

'''
this program is using the khayyam package .I think @Niloofar24 was looking for this
to install just type
sudo pip install khayyam
and if you have two different versions of python on your system :
sudo apt-get install python3-pip
sudo pip3 install khayyam

'''
import khayyam as kh
today_now = kh.JalaliDatetime.now()
print("today's date and time is :",today_now.strftime("%y-%m-%d, %H-%M-%S"))
print()
new_year = kh.JalaliDatetime(1394,1,1,2,15,11)  #which is a saturday
time_left = new_year-today_now

day_hour_minute = str(time_left).split(':')


print( day_hour_minute[0] ,'hours and ',day_hour_minute[1], 'minutes and ', day_hour_minute[2],'seconds left to Iranian new year')
fonzali 0 Light Poster

I forgot to mention that if you go to www.taghvim.com/norooz.html you will see a nice count down timer to new year

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.