File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
33#
4- # Copyright (C) 2021-2025 Intel Corporation
4+ # Copyright (C) 2021-2026 Intel Corporation
55#
66# SPDX-License-Identifier: MIT
77#
88
9- import sys
9+ print ( "26.01" )
1010
11- from datetime import datetime , timezone
12-
13- def convert_ww (epoch ):
14- dt = datetime .fromtimestamp (epoch , timezone .utc )
15-
16- # get some info from epoch
17- yr = int (dt .strftime ("%y" ))
18- doy = int (dt .strftime ("%j" ))
19- # and day of week for Jan 1st
20- dow1 = int (datetime (dt .year , 1 , 1 ).strftime ("%w" ))
21-
22- # number of days in a year
23- _is_leap = yr % 400 == 0 or (yr % 4 == 0 and yr % 100 != 0 )
24- _y_days = 366 if _is_leap else 365
25-
26- _doy = doy - 1 + dow1 # shift day of year to simulate Jan 1st as Sunday
27- _ww = int (_doy / 7 ) + 1 # get workweek
28- _wd = int (_doy % 7 ) # get days of week
29- _y_days = _y_days + dow1 # adjusted number of days in year
30- _w_days = _y_days - _doy + _wd # number of week days to end of year
31-
32- if _w_days < 7 :
33- # last week has less than 7 days
34- yr = yr + 1
35- _ww = 1
36-
37- print ("{:02d}.{:02d}" .format (yr , _ww ))
38- return 0
39-
40- if __name__ == '__main__' :
41- sys .exit (convert_ww (int (sys .argv [1 ])))
You can’t perform that action at this time.
0 commit comments