FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour convert decimal numbers to hours/minute
Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
convert decimal numbers to hours/minute
Posted: Mon Oct 07, 2024 12:38 PM

Dear users

Is it possible to convert decimal numbers to time (hours and minutes)

p.e. each time 10 minutes more

if 18.00 = 18.00 h

then 18.10 = 18.10 h

...

18.60 = 19.00 h

18.70 = 19.10 h

...

18.90 = 19.30 h

Is that possible because I do not see how to count minutes more without doing it with numbers

Thank you

José (local food bank to invite the users of the food bank on a different time)

Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: convert decimal numbers to hours/minute
Posted: Mon Oct 07, 2024 12:44 PM

to make date cards for the whole year with for each date a different hour/minute

Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: convert decimal numbers to hours/minute
Posted: Mon Oct 07, 2024 07:26 PM
Whit the help of saint ChatGPT :)
Code (fw): Select all Collapse
#include "FiveWin.ch"

Function Main()
    LOCAL nHora := 18, nInc := 0.10, i
    LOCAL nHoras, nMinutos, ahoras := {}

    // Ciclo para agregar 10 minutos en cada iteración
    FOR i := 1 TO 40
        // Extraemos la parte entera (hora) y decimal (minutos)
        nHoras := INT(nHora)
        nMinutos := (nHora - nHoras) * 100

        // Agregamos 10 minutos
        nMinutos += 10

        // Si los minutos exceden 60, sumamos 1 hora y ajustamos los minutos
        IF nMinutos >= 60
            nHoras += 1
            nMinutos -= 60
        ENDIF

        // Control para las 24:00 horas, reinicia a 00:00
        IF nHoras >= 24
            nHoras := 0
        ENDIF

        // Reasignamos el valor de nHora en formato numérico
        nHora := nHoras + (nMinutos / 100)

        // Mostramos el nuevo valor de la hora
        AADD(aHoras, { i, nHora} )

    NEXT

    xBrowse(aHoras)

Return NIL
Regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 124
Joined: Sat Dec 05, 2009 12:44 PM
Re: convert decimal numbers to hours/minute
Posted: Tue Oct 08, 2024 04:21 PM

Gracias Carlos por su ayuda !

Continue the discussion