Rem this text file was taken from help contents in QBX (PDS 7.10)
Rem and has been heavily modified for FormatX.bas and is PD 2025.
Rem  v1.0a changes serial date/time functions to support more range values.
Rem    Year between 1753 and 2078 modified to 0001 and 9999.

' Converts a number to a string and formats it according to instructions
' contained in a format expression.
'
'    FORMATX$(expression)
'
'     expression  Numeric expression to format
'
'    PRINT USING fmt$; expression
'
'     fmt$ String expression consisting of display-format characters
'          that detail how the expression is displayed:
'          Date and time formats numeric expression formats
'
'    A format expression (fmt$) can have up to three sections separated by
'     semicolons (;). The first section formats positive values, the second
'     section formats negative values, and the third section formats zeros:
'
'         Usage Result
'         ----------------     ----------------------------------------------
'         One section only     The format applies to all numbers
'         Two sections         The first section applies to positive numbers
'                              and zeros; the second to negative numbers
'         Three sections       The first section applies to positive numbers,
'                              the second to negative numbers, and the third
'                              to zeros
'
'    If you have semicolons with nothing between them, the missing section
'     prevents that type of number from being displayed.
'
' Date and Time Formats
'
'  Date/time serial numbers can be formatted with date/time formats or with
'   numeric formats, since date/time serial numbers are stored as floating-
'   point values. Date and time formats are:
'
'         Symbol   Description
'         ------   ----------------------------------------------------------
'         d        Display the day as a number without leading zeros (1-31)
'         dd       Display the day as a number with leading zeros (01-31)
'         ddd      Display the day as an abbreviation (Sun-Sat)
'         dddd     Display the day as a full name (Sunday-Saturday)
'         ddddd    Display a serial date number as a complete date
'                  (including day, month, and year)
'
'         m        Display the month as a number without leading zeros (1-12)
'         mm       Display the month as a number with leading zeros (01-12)
'         mmm      Display the month as an abbreviation (Jan-Dec)
'         mmmm     Display the month as a full name (January-December)
'
'         y        Display the year as a two-digit number (00-99)
'         yyyy     Display the year as a four-digit number (1900-2040)
'
'         h        Display the hour as a number without leading zeros (0-23)
'         hh       Display the hour as a number with leading zeros (00-23)
'
'         n        Display the minute as a number without leading zeros (0-59)
'         nn       Display the minute as a number with leading zeros (00-59)
'
'         s        Display the second as a number without leading zeros (0-59)
'         ss       Display the second as a number with leading zeros (00-59)
'
'         ttttt    Display a time serial number as a complete time, including
'                  hour, minute, and second
'
'         cccc     Display full date/time in form Mon Jan 01 2010 hh:mm:ss
'
'         AM/PM    (Default) Use the 12-hour clock displaying AM or am with
'         am/pm    any hour before noon; PM or pm with any hour between noon
'                  and 11:59
'         A/P      Use the 12-hour clock displaying A or a with any hour
'         a/p      before noon; P or p with any hour between noon and 11:59
'         
'
' Numeric Expression Formats
'
'  You can use the following symbols to create the format expression used
'   with FORMATX$:
'
'         Value Description
'         ---------------    ------------------------------------------------
'         0                  Digit placeholder
'                             If the number has fewer digits than there are
'                              zeros (on either side of the decimal) in the
'                              format expression, leading or trailing zeros
'                              are displayed.
'                             If the number has more digits to the right of
'                              the decimal point than there are zeros to the
'                              right of the decimal in the format expression,
'                              the number is rounded to as many decimal places
'                              as there are zeros.
'                             If the number has more digits to the left of
'                              the decimal point than there are zeros to the
'                              left in the format expression, the extra digits
'                              are displayed.
'         #                  Digit placeholder
'                             Follows the same rules as for the 0 digit
'                              placeholder, except that extra zeros are not
'                              displayed if the number has fewer digits on
'                              either side of the decimal point than there
'                              are #'s on either side of the format.
'         .                  Decimal point
'                             This symbol determines how many digits (#'s or
'                              0's) display to the right and left of the
'                              decimal point. Note: Some international
'                              settings may cause the comma to be used
'                              as a decimal point rather than a period.
'                             If the format contains only #'s to the left
'                              of this symbol, then numbers smaller than 1
'                              are begun with a decimal point. To avoid this,
'                              you should use 0 as the first digit placeholder
'                              to the left of a decimal point instead of #.
'         %                  Percentage
'                             The expression is multiplied by 100 and the
'                              % character is inserted.
'         ,                  Thousands separator
'                             Separates thousands by commas
'                              (or by periods if the country code has been set to
'                              a country other than the United States) if the
'                              format contains a comma surrounded by #'s or 0's.
'                             Two adjacent commas, or a comma immediately to
'                              the left of the decimal point location (whether
'                              there is a decimal specified or not) means
'                              "Omit the three digits that fall between these
'                              commas, or between the comma and the decimal
'                              point, rounding as needed."  Large numbers can
'                              be scaled using this technique. For example,
'                              the format string "##0,,." can be used to
'                              represent 100 million, as simple 100. Numbers
'                              smaller than 1 million are displayed as 0.
'         E- E+ e- e+        Scientific format
'                             If a format contains one digit placeholder
'                              (0 or #) to the right of an E-, E+, e-, or e+,
'                              Displays the number in scientific
'                              format and inserts an E or e between the number
'                              and its exponent.
'                             The number of 0's or #'s to the right
'                              determines the number of digits in the
'                              exponent.
'                             Use E- or e- to place a minus sign next to
'                              negative exponents. Use a E+ or e+ to place a
'                              minus sign next to negative exponents and a
'                              plus sign next to positive exponents.
'         :  + $ () space   Display literal character
'                             To display a character other than one of these,
'                              precede the character with a backslash (\) or
'                              enclose the character(s) in double quotation
'                              marks ("").
'         \                  Display next character in format string
'                             Many characters in the format string have a
'                              special meaning and cannot be displayed as
'                              literal characters unless they are preceded
'                              by a backslash. The backslash is not
'                              displayed. This is the same as enclosing the
'                              next character in double quotation marks.
'                             Examples of such characters are the date-
'                              and time-formatting characters (y, m, d, h,
'                              s, a, and p) and the numeric-formatting
'                              characters (#, 0, %, E, e, comma, and
'                              period).
'         "abc"              Display text inside double quotes
'                             To include a text string in fmt$, you must
'                              use CHR$(34) to enclose the text (34 is the
'                              ASCII code for double quotation mark).
'         :                  Time separator
'                             The time separator is used to separate hours,
'                              minutes, and seconds when time values are
'                              formatted.
'         /                  Date separator
'                             The date separator is used to separate day,
'                              month, and year when date values are formatted.
'
' Format Specifiers
'
'  The following characters are used to format numeric expressions:
'
'   Character Description
'   ---------   -------------------------------------------------------------
'   #           Digit position
'   -           Placed after digit, prints trailing sign for negative numbers
'   .           Decimal point position
'   ,           Placed left of the decimal point, prints a comma every third
'               digit
'   $$          Prints leading $
'   +           Position of number sign
'   **          Fills leading spaces with *
'   ^^^^        Prints in exponential format
'   **$         Combines ** and $$
'   &           Prints entire string
'   \ \         Prints first n characters, where n is the number of blanks
'               between slashes + 2
'   !           Prints only the first character of the string
'
'   Note: Any character not in this list is printed as a literal.
'
' Date and Time Command Summary
'
'   <DAY Function>           Returns the day of the month from a serial number
'   <HOUR Function>          Returns the hour from a serial number
'   <DATE$ Function>         Returns the current system date (dd-mm-yyyy)
'   <DATE$ Statement>        Sets the current system date
'   <DATESERIAL Function>    Returns a serial number from y%, m%, d% arguments
'   <DATEVALUE Function>     Returns a serial number from a date string
'   <FORMATX$ Function>      Converts a number to a string and formats it
'   <MINUTE Function>        Returns the minute from a serial number
'   <MONTH Function>         Returns the month from a serial number
'   <NOW Function>           Returns serial number equal to current date/time
'   <SECOND Function>        Returns the seconds from a serial number
'   <TIME$ Function>         Returns the current system time (hh:mm:ss)
'   <TIME$ Statement>        Sets the current system time
'   <TIMESERIAL Function>    Returns a serial number from h%, m%, s% arguments
'   <TIMER Statement>        Enables/disables/suspends timer event trapping
'   <TIMEVALUE Function>     Returns a serial number from a time string
'   <WEEKDAY Function>       Returns the day of the week from serial number
'   <YEAR Function>          Returns the year from serial number
'
' Evaluates a date/time serial number and returns the day of the month, a
' value in the range 1 to 31.
'
'    DAY(serial)
'
' Evaluates a date/time serial number and returns the hour, a value between 0
' (12:00 AM) and 23 (11:00 PM)
'
'    HOUR(serial)
'
' Returns a serial number that represents the date of the arguments.
'
'    DATESERIAL(year%, month%, day%)
'
'     year%     Year between 0001 and 9999
'
'     month%    Month between 1 and 12
'
'     day%      Day between 1 and 31
'
' Returns a serial number that represents the date of the argument.
'
'    DATEVALUE(date$)
'
'     date$    Any valid date string between January 1, 0001 and December 31,
'               9999
'
' Evaluates a date/time serial number and returns the minute, a value between
' 0 and 59
'
'    MINUTE(serial)
'
' Evaluates a date/time serial number and returns the month, a value in the
' range 1 to 12
'
'    MONTH(serial)
'
' Evaluates a date/time serial number and returns the seconds, a value between
' 0 and 59
'
'    SECOND(serial)
'
' Serial numbers
'
'  NOW
'
'  A serial number is a date/time code used to represent dates and times.
'   This equates to the date range between January 1, 0001, and December 31,
'   9999 and the time as hh:mm:ss
'
'  Numbers to the left of the decimal point represent the time; numbers to
'   the right of the decimal point represent the date and the float
'   variable stores into 15 decimal places where the left 6 digits is the
'   time and the right 9 digits is the date and is represented as
'   HHMMSS.YYYYMMDDb
'
' Returns a serial number that represents the time of the arguments.
'
'    TIMESERIAL(hour%, minute%, second%)
'
'     hour%      Hour between 0 (12:00 AM) and 23 (11:00 PM)
'
'     minute%    Minute between 0 and 59
'
'     second%    Second between 0 and 59
'
' Returns a serial number that represents the time of the argument.
'
'    TIMEVALUE(time$)
'
'     time$  A time between 0:00:00 (12:00:00 AM) and 23:59:59
'             (11:59:59 PM), time$ value can be entered as
'             "2:24PM" or "14:24"; date information, if included in time$,
'             is ignored
'
' Evaluates a date/time serial number and returns the day of the week.
'
'    WEEKDAY(serial)
'
' Evaluates a date/time serial number and returns the year, a value in range
' 0001 to 9999
'
'    YEAR(serial)
'
