FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Converte Time
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Converte Time
Posted: Mon Nov 19, 2012 10:28 AM
On Tcalex class I have a methos to show the Hour

Code (fw): Select all Collapse
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 March-April 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
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Converte Time
Posted: Mon Nov 19, 2012 01:28 PM
Code (fw): Select all Collapse
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Converte Time
Posted: 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 March-April 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
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Re: Converte Time
Posted: Thu Dec 13, 2018 02:45 PM
THERE IS NO 24.00 !!!!!!
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Converte Time
Posted: Thu Dec 13, 2018 04: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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Converte Time
Posted: 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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Converte Time
Posted: Fri Dec 14, 2018 04:05 PM

cTime:= iif(cTime == "24:00", "00:00", cTime)

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Converte Time
Posted: Fri Dec 14, 2018 08:31 PM
The method can be simplified
Code (fw): Select all Collapse
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Converte Time
Posted: Sat Dec 15, 2018 08: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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Converte Time
Posted: Sun Dec 16, 2018 01: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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Converte Time
Posted: 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 March-April 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

Continue the discussion