curriculum/challenges/english/blocks/daily-coding-challenges-python/69b559d2903b9e4afe9075f9.md
Given a Unix timestamp in milliseconds, return the day of the week.
Valid return days are:
"Sunday""Monday""Tuesday""Wednesday""Thursday""Friday""Saturday"Be sure to ignore time zones.
get_day_of_week(1775492249000) should return "Monday".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_day_of_week(1775492249000), "Monday")`)
}})
get_day_of_week(1766246400000) should return "Saturday".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_day_of_week(1766246400000), "Saturday")`)
}})
get_day_of_week(33791256000000) should return "Tuesday".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_day_of_week(33791256000000), "Tuesday")`)
}})
get_day_of_week(1773576000000) should return "Sunday".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_day_of_week(1773576000000), "Sunday")`)
}})
get_day_of_week(0) should return "Thursday".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_day_of_week(0), "Thursday")`)
}})
def get_day_of_week(timestamp):
return timestamp
from datetime import datetime, timezone
def get_day_of_week(timestamp):
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
dt = datetime.fromtimestamp(timestamp / 1000, tz=timezone.utc)
return days[dt.weekday()]