Converte Time

Converte Time

Postby Silvio.Falconi » Mon Nov 19, 2012 10:28 am

On Tcalex class I have a methos to show the Hour

Code: Select all  Expand view  RUN
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Postby sambomb » Mon Nov 19, 2012 1:28 pm

Code: Select all  Expand view  RUN
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
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Converte Time

Postby Silvio.Falconi » Thu Dec 13, 2018 12:41 pm

But I not see 24.00 but 0.00
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Postby Euclides » Thu Dec 13, 2018 2:45 pm

THERE IS NO 24.00 !!!!!!
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Re: Converte Time

Postby James Bott » Thu Dec 13, 2018 4:48 pm

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Converte Time

Postby Silvio.Falconi » Fri Dec 14, 2018 11:50 am

how I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Postby James Bott » Fri Dec 14, 2018 4:05 pm

cTime:= iif(cTime == "24:00", "00:00", cTime)
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Converte Time

Postby nageswaragunupudi » Fri Dec 14, 2018 8:31 pm

The method can be simplified
Code: Select all  Expand view  RUN
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
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Converte Time

Postby Silvio.Falconi » Sat Dec 15, 2018 8:15 am

Rao
I must insert it or I must make an Ovverride to calex class ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Converte Time

Postby James Bott » Sun Dec 16, 2018 1:39 am

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Converte Time

Postby Silvio.Falconi » Sun Dec 16, 2018 11:22 am

exact. As I did for the rpreview class
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests