StrTrimEx() with flag 0x200



Working with some existing stuff where I had a method now  like this  to return a yyymmddThh:mm:ss string  that I used in several places of the project I'm working on.

INLINE CLASS METHOD now
local ft := ChrR(0,8)
ft64_now(@ft,.T.)
return ft64_GetTs(ft,'%04.4hu-%02.2hu-%02.2huT%02.2hu:%02.2hu:%02.2hu')


But for the new stuff I needed to put this time string into 2 fields one for the date and another for the time, and have just remembered the flag 0x200 of the old ot4xb StrTrimEx() function, so I can keep only digits and the : for the hour, and was written quick this 2 methods.

INLINE CLASS METHOD ts2date(ts)
return StoD( Left(StrTrimEx( ts , "0123456789:",0x200),8) )


and

INLINE CLASS METHOD ts2time(ts)
return SubStr( StrTrimEx( ts , "0123456789:",0x200),9)

One of this days will post an example for the condense string flags, ....






StrTrimEx()

Syntax


StrTrimEx(cStr,cTrimChars,nFlags,chReplaceForCondenseString) --> cStr_trimmed 

cStr
....
cTrimChars
....
nFlags
      0x01 - Trim characters on the left side of the string

      0x02 - Trim characters on the right side of the string

      0x03 - Trim characters on both sides of the string

      0x100 - Condense String

      0x200 - Remove unsafe ( list is safe unless 0x1000 )

      0x1000 - INVERT TABLE  if 0x200 only then list is unsafe

chReplaceForCondenseString
By default a single space

No comments:

Post a Comment