Page 1 of 1

Converte Time

Posted: Mon Nov 19, 2012 10:28 am
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

Re: Converte Time

Posted: Mon Nov 19, 2012 1:28 pm
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
 

Re: Converte Time

Posted: Thu Dec 13, 2018 12:41 pm
by Silvio.Falconi
But I not see 24.00 but 0.00

Re: Converte Time

Posted: Thu Dec 13, 2018 2:45 pm
by Euclides
THERE IS NO 24.00 !!!!!!

Re: Converte Time

Posted: Thu Dec 13, 2018 4:48 pm
by James Bott
Actually, both 00:00 and 24:00 are used. For more info see:

24 Hour Clock

James

Re: Converte Time

Posted: Fri Dec 14, 2018 11:50 am
by Silvio.Falconi
how I can resolve ?

Re: Converte Time

Posted: Fri Dec 14, 2018 4:05 pm
by James Bott
cTime:= iif(cTime == "24:00", "00:00", cTime)

Re: Converte Time

Posted: Fri Dec 14, 2018 8:31 pm
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
 

Re: Converte Time

Posted: Sat Dec 15, 2018 8:15 am
by Silvio.Falconi
Rao
I must insert it or I must make an Ovverride to calex class ?

Re: Converte Time

Posted: Sun Dec 16, 2018 1:39 am
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.

Re: Converte Time

Posted: Sun Dec 16, 2018 11:22 am
by Silvio.Falconi
exact. As I did for the rpreview class