- def trans(logic):
- if logic < 0:
- logic += 2 * 2147483648
- return bin(logic)[2:].zfill(32)
-
- def trans_month(logic_str):
- if logic_str[-1]=='1':
- a = [x + 1 for x in range(0, 31)]
- b = [x == '1' for x in logic_str[:-1]]
- print('每月%s号'%(','.join([str(x) for x, y in zip(a, b[::-1]) if y])))
- else:
- a = [x + 1 for x in range(0,4)]+['最后一']
- b = [x == '1' for x in logic_str[-6:-1]]
- x=','.join([str(x) for x, y in zip(a, b[::-1]) if y])
- a = [x + 1 for x in range(0, 7)]
- b = [x == '1' for x in logic_str[-23:-16]]
- y=','.join([str(x) for x, y in zip(a, b[::-1]) if y])
- print('每月第%s周的周%s' % (x,y))
-
- def trans_week(logic_str):
- a = [x + 1 for x in range(0, 7)]
- b = [x == '1' for x in logic_str[-23:-16]]
- print('每周%s' % (','.join([str(x) for x, y in zip(a, b[::-1]) if y])))
-
- for logic in(-536870909,15,1073741837,1073741839,-1073741809,-1073741811,45,1048586,131116,262188):
- logic_str=trans(logic)
- trans_month(logic_str)
-
- for logic in(6488064,1441792):
- logic_str=trans(logic)
- trans_week(logic_str)
原始数据
monthly_logic
11100000000000000000000000000011
每月1/29/30/31号 -536870909
00000000000000000000000000001111
每月1/2/3号 15
01000000000000000000000000001101
每月2/3/30号 1073741837
01000000000000000000000000001111
每月1/2/3/30号 1073741839
11000000000000000000000000001111
每月1/2/3/30/31号 -1073741809
11000000000000000000000000001101
每月2/3/30/31号 -1073741811
00000000000000000000000000101101
每月2/3/5号 45
00000000000100000000000000001010
每月第1/3个周5 1048586
00000000000000100000000000101100
每月第2/3/最后一个周2 131116
00000000000001000000000000101100
每月第2/3/最后一个周3 262188
weekly_logic
00000000011000110000000000000000
每周1/2/6/日 6488064
00000000000101100000000000000000
每周2/3/5 1441792