[Ajuda] gettime()
#1

Podemos definir:
PHP код:
minutos 60
horas 
60 60
dias 
24 60 60 
gettime trabalha com segundos, portanto a conversгo deve ser em segundos.

Supondo q eu queira converter os segundos em SEGUNDOS, MINUTOS, HORAS e DIAS.

PHP код:

new HORAS 5;
new 
Tempo HORAS 60 60;
Converter(Tempo);
stock Converter(SEGUNDOS)
{
    new 
MINUTOSHORASDIAS;
    
    if(
SEGUNDOS 59)
    {
        
SEGUNDOS 0;
        
MINUTOS += 1;
    }
    if(
MINUTOS 59)
    {
        
MINUTOS 0;
        
HORAS += 1;
    }
    if(
HORAS 23)
    {
        
HORAS 0;
        
DIAS += 1;
    }

Essa tecnica funciona com timers, porйm й falho com gettime.
Alguйm teria uma forma de converter isso sem includes e/ou plugins?
Reply
#2

Bem tens aqui isto que te ajudara a fazer a conversao:

https://sampforum.blast.hk/showthread.php?tid=347605
Reply
#3

Quote:
Originally Posted by PT
Посмотреть сообщение
Bem tens aqui isto que te ajudara a fazer a conversao:

https://sampforum.blast.hk/showthread.php?tid=347605
Pesquisei a respeito e eu sabia q nгo havia necessidade de usar includes adicionais, uma simples stock faz a conversгo com uma lуgica simples... Quando eu achar eu posto aqui.
Reply
#4

Cara usar essa include nao vai afetar nada, alem do mais essa da para colocar o GMT o que a maior parte das tais stocks por ai que tu ve nao suporta...
Reply
#5

Quote:
Originally Posted by PT
Посмотреть сообщение
Cara usar essa include nao vai afetar nada, alem do mais essa da para colocar o GMT o que a maior parte das tais stocks por ai que tu ve nao suporta...
Vou dar sim uma estudada nela, mas a princнpio a stock pra mim faz o q eu necessito.

Essa stock aki...
PHP код:
stock TB_ConvertTime(Seconds)
{
        new 
Minutes;
        if(
Seconds 59)
        {
            
Minutes Seconds 60;
                
Seconds Seconds Minutes 60;
        }
        new 
Hours;
        if(
Minutes 59)
        {
            
Hours Minutes 60;
                
Minutes Minutes Hours 60;
        }
        new 
Days;
        if(
Hours 23)
        {
            
Days Hours 24;
                
Hours Hours Days 24;
        }
        return 
1;

Reply
#6

Nгo vejo necessidade em tentar reinventar a roda, porйm http://pt.stackoverflow.com/question...imestamp/70486
Boa leitura ^^

@Edit como eu disse, nгo hб porque reinventar a roda
https://github.com/Crayder/Time-Conv.../timestamp.inc
https://sampforum.blast.hk/showthread.php?tid=347605
https://sampforum.blast.hk/showthread.php?tid=294054
Reply
#7

Quote:
Originally Posted by Day_
Посмотреть сообщение
Obrigado pelas referкncias. Mas o que vc chama de "reinvenзгo" eu chamo de praticidade. Adicionar uma livraria no GM/FS й fбcil, mas vc precisa estudar a mesma para compreendк-la.
Uma lуgica de conversгo simples estб de bom tamanho. No momento vou utilizar este mйtodo, pois й a primeira vez q utilizo um sistema temporбrio.
Mas obrigado pelo feedback.
Reply
#8

Dб pra trabalhar tambйm o conceito de 'resto'
Reply
#9

pawn Код:
stock ConvertSeconds(input, &year, &month, &day, &hour, &minute, &second) {
    #define MINUTES_IN_HOUR 60
    #define HOURS_IN_DAY 24
    #define DAYS_IN_WEEK 7
    #define DAYS_IN_MONTH 30
    #define DAYS_IN_YEAR 365.2425

    second = input % SECONDS_PER_MINUTE;
    input /= SECONDS_PER_MINUTE;
    minute = input % MINUTES_IN_HOUR;
    input /= MINUTES_IN_HOUR;
    hour = input % HOURS_IN_DAY;
    input /= HOURS_IN_DAY;
    day = input % DAYS_IN_WEEK;
    input /= DAYS_IN_WEEK;
    //week = input & WEEKS_IN_MONTH;
    month = input / WEEKS_IN_MONTH;
    year = floatround(input / DAYS_IN_YEAR, floatround_floor);
}
Exemplo

pawn Код:
new year, month, day, hour, minute, second;
// Hora de regresso em 504853 segundos
ConvertSeconds(504853, year, month, day, hour, minute, second);
Fonte: https://github.com/Crayder/Time-Conv.../timestamp.inc

Eu nгo falo portuguкs , eu sу vi o meu nome e veio para ajudar. Usando ****** Tradutor.
Reply
#10

Vlw man, eu n ia usar a include, mas jб q vc se deu o trabalho de me explicar uma base, n custa tentar!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)