Guest Amarildo Posted December 10, 2006 Report Share Posted December 10, 2006 Ola Pessoal, alguém teria a função para identificar se o horario e PM ou AM, obrg a todo que postarem aqui em meu auxilio, valeu Quote Link to comment Share on other sites More sharing options...
0 Thales Pontes Martins Posted December 10, 2006 Report Share Posted December 10, 2006 Opa, teste isso ->Se você tem um TDateTime e quer saber se é PM ou AM então ->var T : TDateTime; PM : Boolean; begin T:=Now; PM:=((T-Trunc(T)) > 0.5); end;Então se PM for true depois disso é que é PM, senão é AM. Quote Link to comment Share on other sites More sharing options...
0 Churc Posted December 10, 2006 Report Share Posted December 10, 2006 muito bom o código thales ;) Quote Link to comment Share on other sites More sharing options...
0 Guest Visitante Posted December 14, 2006 Report Share Posted December 14, 2006 OLa Pessoal, consegui descrever o comando acima, só não consegui entender como fazer para saber se é PM ou AM, peço ajuda, pois não tenho conhecimentos profundos na materia, obrg pela atenção, aguardo por maiores informacoes, obrg Quote Link to comment Share on other sites More sharing options...
0 Thales Pontes Martins Posted December 14, 2006 Report Share Posted December 14, 2006 A função PM retorna True se for PM e False se for AM ->Function PM(T : TDateTime) : boolean; begin Result:=((T-Trunc(T)) >= 0.5); end; if (PM(Now)) then ShowMessage('O horário atual é PM') else ShowMessage('O horário atual é AM'); Quote Link to comment Share on other sites More sharing options...
0 Micheus Posted December 14, 2006 Report Share Posted December 14, 2006 Complementando...Por que testar se o valor decimal é maior que 0.5?Porque o TDateTime é um Double, onde a parte inteira armazena a data e a parte fracionária armazena as horas. Então, 0.5 equivale à metade de 24:00h. Deste modo se for maior que 0.5, significa que a hora já passou do meio dia.[]s Quote Link to comment Share on other sites More sharing options...
Question
Guest Amarildo
Ola Pessoal, alguém teria a função para identificar se o horario e PM ou AM, obrg a todo que postarem aqui em meu auxilio, valeu
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.