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 - set epoch to control the epoch flag http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 set epoch to        Control the epoch flag
------------------------------------------------------------------------------
 Syntax
   set epoch to uYear

 Arguments
   uYear is a numeric specifying a century and decade for date expansion.

 Description
   The set epoch to command allows modifying 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.

   As an example, when the year in the cDate argument of the ctod()
   function only consists of two digits, Force by default assumes the 20th
   century, e.g.

   "07/04/00" is expanded into "07/04/1900"

   Issuing the command

   set epoch to 1960

   defines 1900 as the century, and 60 as the decade. In this case

   "07/04/60" is expanded into "07/04/1960"

   while

   "07/04/59" is 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 year, because in this case ctod() gets called
   internally.

 Example
   #define EXAMPLE_DATE
   #include example.hdr

   proc Test_setepochto
   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 demonstates 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_setepochto()
   endproc

See Also: ctod() getepoch()

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