JetNoLag: The Traveller’s Time

Aniket Majumder
5 min readJul 5, 2021

As someone with two countries I can reasonably call home, travel’s always been a part of my life. I’ve bounced from airport to airport, and I’ve been shot with jet lag. It’s the worst part of flying; for me, it takes a week at least to adjust to the conditions of the place I’m going to. Adjusting has to happen before travelling, but there’s no good solution for a progressive adjustment to the other timezone. Here’s our solution at JetNoLag.

Our logo

In short, we created a progressive timer, where we take in the time difference and the number of days to create an output that has a calendar of days and times. Here’s an overview of the code:

from guizero import *
from datetime import *
import datetime

We imported three libraries, guizero being our UI to display something other than the terminal and datetime being our library to reference the times and dates the user would input.

times = ["GMT -12", "GMT -11", "GMT -10", "GMT -9", "GMT -8", "GMT -7", "GMT -6", "GMT -5", "GMT -4", "GMT -3", "GMT -2", "GMT -1","GMT +0", "GMT +1", "GMT +2", "GMT +3", "GMT +4", "GMT +5", "GMT +6", "GMT +7", "GMT +8", "GMT +9", "GMT +10", "GMT +11", "GMT +12"]

app = App(title = "Jet No Lag ", width = "1200", height = "700", bg = "#D8E0FF")

def submit():
CZ = currentZone.value
DZ = destinationZone.value
cz = int(times.index(CZ))
dz = int(times.index(DZ))
timeDifference = (dz - 12) - (cz -12)


a = datetime.datetime(int(year.value), int(month.value), int(day.value))
dateDifference = a.date() - date.today()
daysDate = dateDifference.days
change = int(timeDifference) / int(daysDate)*60 #this is calculating how much time needs to be increased or decreased by in minutes each day

The times variable is to list out all possible timezones that can be selected, while the app is the basic outline of the application. The submit function had the time difference calculated from the current timezone and the destination’s timezone.

The a variable is used to determine the date, which is taken from a user input. We then take the difference in days to get the second part of our goal; the number of days the user has to prepare.

The change variable is the kingfish here. We have both variables for time and days, and now we can calculate the time difference to stagger day by day.

today = date.today()t = datetime.datetime(year = int(today.year) , month = int(today.month), day = int(today.day) ,hour = int(sliderHour.value), minute = int(sliderMinutes.value)) #formating the time the user input into datetime


for i in range(daysDate): #works out the time each day and adds it to the box
newTime = t + timedelta(days = 1, minutes = change)
outputDay.value += str(newTime)
outputDay.value += "\n"
t = newTime

The t variable is to take the inputted date and format it correctly, while we used a for loop to list out all the times from day to day.

name = Text(app, text = "Jet No Lag ✈", size = 50, align = "top", color = "#000000")

description = Text(app,
text = "No one likes jetlag. Input information about your trip and get a custom sleep schedule to \n follow before your departure to transition smoothly into your new time zone."
, size = 20 , color = "#000000")


questions = Box(app, layout = "grid")
currentZoneText = Text(questions, text = "\nPick your current locations time zone", grid = [0,2])

currentZone = Combo(questions,
options = ["GMT -12", "GMT -11", "GMT -10", "GMT -9", "GMT -8", "GMT -7", "GMT -6", "GMT -5", "GMT -4", "GMT -3", "GMT -2", "GMT -1",
"GMT +0", "GMT +1", "GMT +2", "GMT +3", "GMT +4", "GMT +5", "GMT +6", "GMT +7", "GMT +8", "GMT +9", "GMT +10", "GMT +11", "GMT +12"],
selected = "GMT", width = 20, grid = [0,4])
currentZone.bg = "white"

destinationZoneText = Text(questions, text = "\nPick your destination locations time zone", grid = [0,6])

destinationZone = Combo(questions,
options = ["GMT -12", "GMT -11", "GMT -10", "GMT -9", "GMT -8", "GMT -7", "GMT -6", "GMT -5", "GMT -4", "GMT -3", "GMT -2", "GMT -1",
"GMT +0", "GMT +1", "GMT +2", "GMT +3", "GMT +4", "GMT +5", "GMT +6", "GMT +7", "GMT +8", "GMT +9", "GMT +10", "GMT +11", "GMT +12"],
selected = "GMT", width = 20, grid = [0,8])
destinationZone.bg = "white"
tripdate = Text(questions, text = "\nDate of Trip", grid = [6,2], )

day = Combo(questions,
options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14","15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29","30", "31"],
selected = "1", width = 10, grid = [6,4])
day.bg = "white"

month = Combo(questions,
options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
selected = "1", width = 10, grid = [6,5])
month.bg = "white"

year = TextBox(questions, text = "2021", width = "20", height = "87", grid = [6,6])
year.bg = "white"

wakeup = Text(questions, text = "\nUsual Wakeup Time", grid = [6,8])
sliderHour = Slider(questions, start = "0", end = "23", grid = [6,9])
sliderMinutes = Slider(questions, start = "0", end = "59", grid = [6, 10])

Although this looks like a lot of code, it is just an input section. We have the user input their destination times and their current times, to get us something like this:

Inputs
submit_btn = PushButton(questions, text = "Submit", command = submit, grid = [7, 12])
submit_btn.bg = "green"
submit_btn.color = "white"

text = Text(questions, text = "Sleep Schedule", grid = [9,2])
outputDay = Text(questions, text = "", grid = [9,3])


outputDay.bg = "#c3c3c7"
outputDay.text_color = "green"


app.display()

The submit function will eventually output a calendar of times in a grid. Check the final result out!

Check out our entire project here!

Github

TL;DR: We created a progressive alarm that takes in the days to prepare and the timezone difference.

--

--