diff --git a/AutomationScripts/Current Time Stamps/Images/Output.png b/AutomationScripts/Current Time Stamps/Images/Output.png new file mode 100644 index 000000000..9fc79da78 Binary files /dev/null and b/AutomationScripts/Current Time Stamps/Images/Output.png differ diff --git a/AutomationScripts/Current Time Stamps/README.md b/AutomationScripts/Current Time Stamps/README.md new file mode 100644 index 000000000..306b04902 --- /dev/null +++ b/AutomationScripts/Current Time Stamps/README.md @@ -0,0 +1,22 @@ +## Description: +- My project works on displaying Current Time Stamps +- To create GUI Calendar Using Python, we will need to import two Python modules one for creating GUI and another to get year data. +- **Pendulum**, Pendulum is one of the libraries in python which provides easily manages complex date manipulations better than native DateTime instances. It also manages timezones. +- And for the speaking purpose, we will use **pyttsx3**. + +## Procedure: +```python +import pendulum +import pyttsx3 +``` +- First after importing modules. +- After that we will make a function **speak()** in which we will set the rate of speaking and the type of voice. +- Then we will take input from user for which year you want to display the calendar. +- After that in code section we will first use **pendulum.now()** which will tell the current date and time of that zone. +- After displaying it, a bot voice will ask you to enter a location which is evaluated in try and except block. + +## Sample Output: +![LGM](https://github.com/AmitGupta700/Awesome_Python_Scripts/blob/main/AutomationScripts/Current%20Time%20Stamps/Images/Output.png) + +## For any query please contact: +LinkedIn diff --git a/AutomationScripts/Current Time Stamps/current_time_stamps.py b/AutomationScripts/Current Time Stamps/current_time_stamps.py new file mode 100644 index 000000000..67921a3d3 --- /dev/null +++ b/AutomationScripts/Current Time Stamps/current_time_stamps.py @@ -0,0 +1,41 @@ +#Code for time in different timezones + +#importing modules +import pendulum +import pyttsx3 #for speaking purpose + +#function for speaking +def speak(text): + engine = pyttsx3.init() + engine.setProperty("rate", 170) #rate of speaking + voices = engine.getProperty("voices") + engine.setProperty("voice", voices[1].id) #for female voice + engine.say(text) + engine.runAndWait() + +# Code + +speak("Hello! I will convert time in desired timezones.") + +#current details +d1 = pendulum.now() + +#splitting for getting date and time only +dt1 = str(d1).split(".") + +speak("Here's your current timezone with current date and time") +print(f"Current timezone : {d1.timezone_name}") #for displaying timezone +print(f"Current date and time: {dt1[0]}") #as we splited time and timezon + +speak("Now enter the zone you wish to see the time!") +i = input("Enter here: ") + +#details for inputed timezone +try: + d2 = pendulum.now(i) + dt2 = str(d2).split(".") + speak("Here's desired details") + print(f" Current date and time for {d2.timezone_name} : {dt2[0]}") +except Exception as e: + speak("Looks like you have entered incorrect timezone!") + speak("Please check it and try again!") \ No newline at end of file diff --git a/AutomationScripts/Current Time Stamps/requirements.txt b/AutomationScripts/Current Time Stamps/requirements.txt new file mode 100644 index 000000000..99896bf57 --- /dev/null +++ b/AutomationScripts/Current Time Stamps/requirements.txt @@ -0,0 +1,2 @@ +import pendulum +import pyttsx3 \ No newline at end of file