-
Notifications
You must be signed in to change notification settings - Fork 0
/
datas_br.py
29 lines (21 loc) · 945 Bytes
/
datas_br.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from datetime import datetime, timedelta
class DatasBr:
def __init__(self):
self.momento_cadastro = datetime.today()
def __str__(self):
return self.formata_data()
def mes_cadastro(self):
mes_do_ano = ['janeiro','fevereiro','março','abril',
'maio','junho','julho','agosto','setembro','outubro','novembro','dezembro']
mes_cadastro = self.momento_cadastro.month
return mes_do_ano[mes_cadastro-1]
def dia_semana(self):
dia_semana = ['segunda','terça','quarta','quinta','sexta','sabado','domingo']
dia_cadastro = self.momento_cadastro.weekday()
return dia_semana[dia_cadastro]
def formata_data(self):
data_formatada = self.momento_cadastro.strftime('%d/%m/%Y %H:%M')
return data_formatada
def tempo_cadastrado(self):
tempo_cadastro = datetime.today() - self.momento_cadastro
return tempo_cadastro