SHOW:
|
|
- or go back to the newest paste.
1 | #/usr/bin/python | |
2 | # https://www.facebook.com/groups/python.ar.community/ | |
3 | ||
4 | date = raw_input('Entrer un date sous la forme jj/mm/aaaa : ') | |
5 | ||
6 | jj = int(date[:2]) # prendre le jour | |
7 | mm = int(date[3:5]) # prendre le mm | |
8 | aaaa = int(date[6:]) # prendre l'aaaa | |
9 | ||
10 | if mm == 1 or mm == 3 or mm == 5 or mm == 7 or mm == 8 or mm == 10 or mm == 12: nbj = 31 | |
11 | elif mm == 4 or mm == 6 or mm == 9 or mm == 11 : nbj = 30 | |
12 | elif mm == 2 : | |
13 | bis = (aaaa % 4 == 0) and (aaaa % 100 != 0) or (aaaa % 400 == 0) # voir si l'anne est bissextile | |
14 | if bis == True: nbj = 29 | |
15 | else : nbj = 28 | |
16 | ||
17 | if jj != nbj : jj += 1 | |
18 | elif mm == 12 : | |
19 | jj = 01 | |
20 | mm = 01 | |
21 | aaaa += 1 | |
22 | else : | |
23 | jj = 1 | |
24 | mm += 1 | |
25 | ||
26 | jj = str(jj) ; mm = str(mm) ; aaaa = str(aaaa) | |
27 | ||
28 | if len(jj) == 1 : jj = '0' + jj | |
29 | if len(mm) == 1 : mm = '0' + mm | |
30 | ||
31 | print '\n'+jj+'/'+mm+'/'+aaaa |