convert decimal numbers to hours/minute

convert decimal numbers to hours/minute

Postby jds » 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)
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: convert decimal numbers to hours/minute

Postby jds » Mon Oct 07, 2024 12:44 pm

to make date cards for the whole year with for each date a different hour/minute
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm

Re: convert decimal numbers to hours/minute

Postby Cgallegoa » Mon Oct 07, 2024 7:26 pm

Whit the help of saint ChatGPT :)

Code: Select all  Expand view
#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-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 492
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: convert decimal numbers to hours/minute

Postby jds » Tue Oct 08, 2024 4:21 pm

Gracias Carlos por su ayuda !
jds
 
Posts: 122
Joined: Sat Dec 05, 2009 12:44 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests