Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.7 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69b559d2903b9e4afe9075f9 Challenge 239: What Day Is It? 29 challenge-239

--description--

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.

--hints--

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")`)
}})

--seed--

--seed-contents--

def get_day_of_week(timestamp):

    return timestamp

--solutions--

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()]