FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MATHEMATICS

Fix the Y2K problem


Message to all who asked for the international compliant Date conversion routines.

These have been updated to include date conversions to and from the ISO 8601 format (CCYY/MM/DD) which the MacOS does not directly support as yet.

The previously promised routines that take minimum loose text such as "8/1" and converting them to the full local date record have been updated. These are ideal for Edit Fields where a user may not bother to type in the year (for example) and the program makes the necessary changes. The routines use the International Utilities (IU) to ascertain if the local date format is DD/MM/YY or other variants and reacts accordingly.

Examples have been included that also allow you to calculate durations between two dates where again only the bare minimum text has been entered. Ideal for those Year 2000 compliant calculations.

The file is called Date Time Primer and is available from the Source Code Library in the FB Developer Corner located at:

<http://www.ScorpionResearch.com/futurebasic/>

Any feedback or suggested improvements would be appreciated.

Deep


The following seems to work for the KEY.FLTR - Month to make it K2Y compliant (for PG PRO).

This code should replace the code in the Key.FLTR module, FN KFmonthFld. Look for the "LONG IF mm" line and replace from there until the "END FN". I left the original lines in as comments. The only real difference in how this works from the original is that if the person types in a third digit for the year, i.e. "04/099", it changes it back to "04/09" rather than the original code which would change it to "04/99".

If you want to make this change permanent you will need to go into Program Generator and replace the TEXT resource with ID 3006.

LONG IF mm
  newDate$ = "0" + MID$(STR$(mm),2) + "/"
  newDate$ = RIGHT$(newDate$,3)
  theDate$ = MID$(theDate$,chop + 1)
  chop = 0
END IF
IF theDate$ = "" THEN "Expire Key Done"

DO
  flag = _zTrue
  LONG IF LEN(theDate$)
'LONG IF PEEK(@theDate$ + 1) < _"1" OR PEEK(@theDate$ + 1) > _"9"
    LONG IF PEEK(@theDate$ + 1) < _"0" OR PEEK(@theDate$ + 1) > _"9"
      theDate$ = MID$(theDate$,2)
      flag = _false
    END IF
  END IF
UNTIL flag

IF theDate$ = "" THEN "Expire Key Done"

LONG IF LEN(newDate$)
  DO
    flag = _zTrue
    LONG IF LEN(theDate$)
'LONG IF PEEK(@theDate$ + 1) < _"1" OR PEEK(@theDate$ + 1) >_"9"
      LONG IF PEEK(@theDate$ + 1) < _"0" OR PEEK(@theDate$ + 1) > _"9"

      theDate$ = MID$(theDate$,2)
      flag = _false
    END IF
  END IF
UNTIL flag

yy = VAL(theDate$)
'LONG IF yy
LONG IF yy OR LEFT$(theDate$,1) = "0"
' t$ = MID$(STR$(yy),2)
  t$ = theDate$
'IF LEN(t$) > 2 THEN t$ = RIGHT$(t$,2)
    LONG IF LEN(t$) > 1
      LONG IF MID$(t$,2,1) < "0" OR MID$(t$,2,1) > "9"
        t$ = LEFT$(t$,1)
      XELSE
        t$ = LEFT$(t$,2)
      END IF
    END IF
    newDate$ = newDate$ + t$
  END IF
END IF

"Expire Key Done"
LONG IF LEN(newDate$)
  EDIT$(WINDOW(_EFnum)) = newDate$
  SETSELECT WINDOW(_EFTextLen),WINDOW(_EFTextLen)
END IF

Rick Good