Converte Time

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Converte Time

Post by Silvio.Falconi »

On Tcalex class I have a methos to show the Hour

Code: Select all

METHOD ConvertTime( nTime, l24 ) CLASS TCalEx
   
   local cTime
   local nHour, nMinutes
   local nAdj := 0

   DEFAULT l24 := .F. 
   
   if ! l24
      if nTime > 1259 // 12:59 pm
         nAdj = 1200
      endif
      nHour    := Int( ( nTime - nAdj ) / 100 )
      nMinutes = ( nTime - nAdj ) - ( nHour * 100 )
      cTime    = Str( nHour, 2 ) + ":" + StrZero( nMinutes, 2 ) + " " + If( nTime > 1159, "pm", "am" )
   else 
      nMinutes = If( nTime  == 0, 0, Val( Right( StrZero( nTime, 4 ), 2 ) ) )
      nHour    = If( nTime  == 0, 0, ( nTime - nMinutes ) / 100 )
      cTime    = Str( nHour, 2 ) + ":" + StrZero( nMinutes, 2 )
   endif

return cTime


HOw I can make If the Hour is major of 12.59 to show 13.00 |14.00|15.00|16.00|17.00 -----> 23.30 ?
I saw also the method want l24 value but on tcalex converte is called with ConvertTime( nTime) and the paramter l24 is not set
Perhaps if we change oview:lampm ....

thanks
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
sambomb
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil
Contact:

Re: Converte Time

Post by sambomb »

Code: Select all

METHOD ConvertTime( nTime, l24 ) CLASS TCalEx
   
   local cTime
   local nHour, nMinutes
   local nAdj := 0

   DEFAULT l24 := .F. 
   
   if ! l24
      if nTime > 1259 // 12:59 pm
         nAdj = 1200
      endif
      nHour    := Int( ( nTime - nAdj ) / 100 )
      nMinutes = ( nTime - nAdj ) - ( nHour * 100 )
      cTime    = Str( nHour, 2 ) + ":" + StrZero( nMinutes, 2 ) + " " + If( nTime > 1159, "pm", "am" )
//-- EDIT
      cTime := iif( Right(cTime,2) = "pm", StrZero( nHour+12, 2 ) + ":" + StrZero( nMinutes, 2 ), StrZero( nHour, 2 ) + ":" + StrZero( nMinutes, 2 ) )
   else 
      nMinutes = If( nTime  == 0, 0, Val( Right( StrZero( nTime, 4 ), 2 ) ) )
      nHour    = If( nTime  == 0, 0, ( nTime - nMinutes ) / 100 )
      cTime    = Str( nHour, 2 ) + ":" + StrZero( nMinutes, 2 )
   endif

return cTime
 
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Post by Silvio.Falconi »

But I not see 24.00 but 0.00
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Euclides
Posts: 144
Joined: Wed Mar 28, 2007 1:19 pm

Re: Converte Time

Post by Euclides »

THERE IS NO 24.00 !!!!!!
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Converte Time

Post by James Bott »

Actually, both 00:00 and 24:00 are used. For more info see:

24 Hour Clock

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Post by Silvio.Falconi »

how I can resolve ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Converte Time

Post by James Bott »

cTime:= iif(cTime == "24:00", "00:00", cTime)
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Converte Time

Post by nageswaragunupudi »

The method can be simplified

Code: Select all

METHOD ConvertTime( nTime, l24 ) CLASS TCalex

   local cAmPm    := ""

   nTime          := If( nTime == 0, 2400, nTime ) // if to show 24:00 instead of 00:00
   if l24 == .t.
      cAmPm       := If( nTime > 1159, " pm", " am" )
      nTime       := If( nTime > 1259, nTime - 1200, nTime )
   endif

return TRANSFORM( nTime, "@RL 99:99" ) + cAmPm
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Post by Silvio.Falconi »

Rao
I must insert it or I must make an Ovverride to calex class ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Converte Time

Post by James Bott »

An override. You don't want to modify the original class since you would then have to do the modification for each new version of FW.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Post by Silvio.Falconi »

exact. As I did for the rpreview class
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply