Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - ctod() convert a character string into a date value http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ctod()              Convert a character string into a date value
------------------------------------------------------------------------------
 Declaration
   date.hdr

 Syntax
   func date ctod extern
   param const char cDate

 Arguments
   cDate is the date string to convert.

 Return
   The date value corresponding to the passed string.

 Description
   The ctod() function converts a character string into a date value. ctod()
   interprets the cDate according to the current status of set date.
   When the year in cDate only consists of two digits, Force by default
   assumes the 20th century, e.g.

   "07/04/00" gets internally expanded into "07/04/1900"

   Together with the set epoch to command, you may modify the expansion of
   two-digit years. All years are expanded into the century specified with
   set epoch to, or into the next century, depending on the decade specified.

   Here is an example:

   set epoch to 1960

   defines 1900 as the century, and 60 as the decade.

   07/04/60 gets expanded into 07/04/1960

   where

   07/04/59 gets expanded into 07/04/2059

   This means that two-digit years which are greater or equal to the
   specified decade will be expanded with the century specified, where years which
   are less than the decade will be expanded with the next century.

   Note that Force internally always operates with four-digit years, i. e. all
   other date functions correctly handle the century. The only exception is
   the ctod() function when used with a two-digit year, as Force cannot tell
   which century you mean in this case. The same is true if you do a get on
   a date field which a 2-digit picture for the year, because in this case
   ctod() gets called internally.

 Example
   #define EXAMPLE_DATE
   #include example.hdr

   proc Test_ctod
   set century on                // We need this to have dates displayed with
                                 // four-digit years.
   set epoch to 1900             // Let Force assume all two-digit years to
                                 // fall into the 20th century (this is the
                                 // default).
   ? ctod( "07/04/50" )          // Output: 07/04/1950
   set epoch to 1980             // Let Force assume that two-digit years
                                 // from 00 to 49 fall into the 21st century.
   ? ctod( "07/04/50" )          // Output: 07/04/2050
   
   // This example demonstrates how Force's date functions react on
   // the set epoch command (Note: the shown output was created on
   // Feb 02, 1996, i.e. the real output may differ from that.
   
   set epoch to 1900
   ? daysbtwdates( today(), ctod( "01/01/50" ) )       // Output: -16833
   
   set epoch to 1980
   ? daysbtwdates( today(), ctod( "01/01/50" ) )       // Output:  19692
   endproc

   proc main
   Test_ctod()
   endproc

See Also: dtoc() fdtod() itod() set century set date set epoch to

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson