DMY()

DMY()

Returns the date as a string in DD Month YY format

Syntax

       DMY([<dDate>], [<lMode>]) --> cDate

Arguments

<dDate> Designates the date from which to create a string. The default is the system date.

<lMode> Designates whether to insert a period (.) after the day (see Examples). The default is no period (.F.).

Returns

DMY() returns a character string in “DD[.] Month YY” format or “DD[.] Month YYYY” format.

Description

Use DMY() to return the date as a character string using the day, name of month, and year. The SET CENTURY ON/OFF switch determines whether or not the year is displayed in two or four digits. If the <lMode> parameter is designated .T., the function builds in a “.” after the day designation. If no date is designated as a parameter, the function automatically uses the current system date.

Note

. The month name returned depends on which CA-Clipper nations module is in use.

Examples

       .  Display the system date (1/1/89):
              SET CENTURY OFF
              ? DMY()                            // 1 January 89
           .  With ".":
              ? DMY(.T.)                         // 1. January 89
           .  Display a different date:
              SET CENTURY ON
              ? DMY(CTOD("02/01/89"), .T.)       // 1. February 1989

Compliance

DMY() is compatible with CT3’s DMY().

Platforms

All

Files

Source is dattime2.prg, library is libct.

See also

MDY()

DaysToMonth()

DaysToMonth()

Total number of days from first of Jan to beginning of nMonth.

Syntax

       DaysToMonth( <nMonth>, <lLeapYear> ) -> nDaysToMonth

Arguments

<nMonth> Number of month

<lLeapYear> Is year is leapyear

Description

lLeap is FALSE for a non-leap year but TRUE if it is. If so and nMonth is greater than 2, ndays is incremented

Compliance

DaysToMonth() is a new function in Harbour’s CT3 library.

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

DaysInMonth()

DaysInMonth()

DaysInMonth()

Returns the number of days in month

Syntax

       DAYSINMONTH (<nMonth>, <lLeapYear>) -> nDaysInMonth

Arguments

<nMonth> Number of month

<lLeapYear> Is year is leapyear

Returns

<nDaysInMonth> days count in <nMonth>

Description

DaysInMonth() returns days count in <nMonth>

Examples

      ? DaysInMonth( hb_SToD( "20000101" ) ) // -> 31

      ? DaysInMonth( hb_SToD( "20000201" ) ) // -> 29

Compliance

DaysInMonth() is a new function in Harbour’s CT3 library.

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

DaysToMonth()

CToN()

CToN()

Converts a numeric string into a different base

Syntax

       CToN( <xNumber>[, <nBase>][,<lMode>] ) -> <nInteger>

Arguments

<cNumericstring> Designates a numeric string to convert into a number in base <nBase>.

<nBase> Designates the number base to use in the conversion. Can be in the range of 2 to 36. The default is the decimal system, base 10.

<lMode> When designated as .T., allows a negative result. The default allows only positive results.

Returns

CToN() returns the converted number that corresponds to the string. The values lie in the range of 0 and 65535 or, if <lMode> is .T., in the range of -32768 and +32767.

Description

CToN() offers a number of ways to covert a number string into numeric data format. Almost any number can be converted, as long as the base <nBase> for the number system lies between 2 and 36.

Notes

. The <cNumericstring> string is automatically TRIMmed left and right. . If you have invalid parameters or combinations, the function returns a value of 0.

Examples

       .  Convert to base 10:
              ? CToN("60000")                    // Result:  60000
           .  Convert to base 2:
              ? CToN("11", 2)                    // Result:  3
              ? CToN("1110101001100000", 2)      // Result:  60000
           .  Convert to base 16:
              CToN("A", 16)                      // Result:  10
              ? CToN("ABCD", 16)                 // Result:  43981
              ? CToN("FFFF", 16, .T.)            // Result:  -1
           .  Convert to base 36:
              ? CToN("XXP", 36)                  // Result:  43981

Platforms

All

Files

Source is numconv.prg, library is libct.

Seealso

NToC()

CToMonth()

CToMonth()

Convert name of month to its ordinal number

Syntax

       CToMonth( <cName> ) -> nOrdinal

Argument

<cName> Designates the name of one of the 12 months.

Returns

CToMonth() returns the number for the designated month name.

Description

Use CToMonth() to change the name of a month into a number. January corresponds to 1, February 2, etc.. If the function returns a 0 value, then an invalid parameter has been passed. If you shorten the month name, use explicit abbreviations to return an accurate return value.

Notes

. Uppercase and lowercase letters do not affect the name of the month. . The function’s operation depends on the country-specific adaptation of your Harbour compiler. With an English version of Harbour, only English month names are recognized.

Examples

       .  Show the number for January:
              ? CToMonth("January")      // Result: 1
           .  Show several ways to determine the month number for August:
              ? CToMonth("AUGUST")       // Result: 8
              ? CToMonth("August")       // Result: 8
              ? CToMonth("Au")           // Result: 8
           .  The number for April:
              ?CToMonth("A")             // Result: 4

Compliance

CToMonth() is compatible with CT3’s CToMonth().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

NToCMonth()

CToF()

CToF()

Converts a special 8-byte string into a floating point number

 

Syntax

       CToF( <cFloatingPointNumber> ) --> nFloatingPointNumber

Arguments

<cFloatingPointNumber> Designate a string that contains a Harbour number in flotaing point format.

Returns

CToF() return the floating point number that corresponds to the string passed.

ATTENTION: different implementations or platforms of Harbour, they could produce different format in the string returned by FTOC().

Description

Character strings created with FTOC() or XTOC() are convert into Harbour floating point number Note that when you use XTOC(), character strings or portions of character strings, can be switched back, if they have been displayed as Harbour floating point numbers.

Examples

       .  Change a number and then change it back:
              CToF(FTOC(1234.55))        // Result:  1234.55
           .  This also works for XTOC():
              ? CToF(XTOC(1234.55))      // Result:  1234.55

Platforms

All

Files

Source is ftoc.c, library is libct.

Seealso

FToC(), XToC()

CToDoW()

CToDoW()

Convert name of day of the week to its ordinal number

Syntax

       CToDoW( <cDayName> ) -> <nOrdinal>

Argument

<cDayName> Name of day to convert to ordinal number

Return

<nOrdinal> Ordinal number of <cDayName>

Description

Use CToDoW() to change the name of a day of the week to a number. Sunday corresponds to 1, Monday 2, etc.. If the function returns a 0 value, an invalid parameter has been passed. You can shorten the day names, but these abbreviations must be explicit to return an accurate value.

Notes

. Uppercase and lowercase letters do not affect the name of the day of the week. . The function’s operation depends on the country-specific adaptation of your CA-Clipper compiler. With an English version of CA-Clipper, only English day names are recognized.

Example

       PROC MAIN()
          SETMODE( 25, 80 )
          CLS
          SET DATE GERM
          SET CENT ON
          ? "CToDoW('Sunday') :", CToDoW('Sunday') // 1
          *  Show several ways to get the day of
          *  the week for Wednesday:
          ? "CToDoW('WEDNESDAY') :", CToDoW('WEDNESDAY')      // 4
          ? "CToDoW('Wednesday') :", CToDoW('Wednesday')      // 4
          ? "CToDoW('Wed') :",CToDoW('Wed')                   //  4
          *  What number of the day of the week is Monday?
          ? "CToDoW( 'M' ) :", CToDoW( 'M' ) //  2
          ?
          WAIT "EOF CTODOW.prg"
       RETURN // MAIN

Compliance

CToDoW() is compatible with CT3’s CToDoW().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

NToCDoW()