How to get week number since epoch? Like millis?
07:50 10 Oct 2020

I'm modeling a weekly reporting store in DynamoDb.

I'm thinking the best way to identify the report-records is by their respective week number since 1970. Much like epoch milliseconds.

Therefore:

  1. How to get to the current week number since 1970?
  2. How to get start and end dates given such week number?

Considering all the possible edge cases I might not be aware of, like daylight savings and similar, I'm quite uncomfortable trying to solve this.


Clarifications:

  • Week starts Sunday night at midnight.
  • In order to work out the exact time, the function 1. receives the desired UTC offset in minutes. (I'm open to suggestions here)
javascript node.js typescript datetime timezone