SetDate() function

Post Reply
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

SetDate() function

Post by Wanderson »

Hi

SetDate() function don't work correct, i try:

SetDate(02,01,2006) and returns 01/01/2006

Why?

Thanks.
Fwh2.6
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Wanderson,

This sample works ok. Could you please try it ? Thanks.

Code: Select all

function Main()

  local dToday := Date() 

  SET DATE FRENCH 

  SetDate( 02, 01, 2006 )

  MsgInfo( Date() )

  SetDate( Day( dToday ), Month( dToday ), Year( dToday ) )

  MsgInfo( Date() )  

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Post by Wanderson »

Antonio Linares wrote:Wanderson,

This sample works ok. Could you please try it ? Thanks.

Code: Select all

function Main()

  local dToday := Date() 

  SET DATE FRENCH 

  SetDate( 02, 01, 2006 )

  MsgInfo( Date() )

  SetDate( Day( dToday ), Month( dToday ), Year( dToday ) )

  MsgInfo( Date() )  

return nil
Antonio don't work for me. This code returns 01/01/2006 and after command SetDate( Day( dToday ), Month( dToday ), Year( dToday ) ) returns 17/01/2006, correct is 18/01/2006. Whats i do rong?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Wanderson,

You should have this code in source\function\datetime.c:

Code: Select all

CLIPPER SETDATE( PARAMS )                  // nDay, nMonth, nYear
{
   WORD wYear  = _parni( 3 );
   WORD wMonth = _parni( 2 );
   WORD wDay   = _parni( 1 );

   #ifndef __FLAT__
      _CX = wYear;
      _DH = wMonth;
      _DL = wDay;
      _AH = 0x2B;
      _AL = 0;

      Dos3Call();                     // asm int 0x21;

      _retl( _AL == 0 );
   #else
      SYSTEMTIME st;

      GetSystemTime( &st );
      st.wYear  = wYear;
      st.wMonth = wMonth;
      st.wDay   = wDay;
      _retl( SetSystemTime( &st ) );
   #endif
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Post by Wanderson »

Antonio Linares wrote:Wanderson,

You should have this code in source\function\datetime.c:

Code: Select all

CLIPPER SETDATE( PARAMS )                  // nDay, nMonth, nYear
{
   WORD wYear  = _parni( 3 );
   WORD wMonth = _parni( 2 );
   WORD wDay   = _parni( 1 );

   #ifndef __FLAT__
      _CX = wYear;
      _DH = wMonth;
      _DL = wDay;
      _AH = 0x2B;
      _AL = 0;

      Dos3Call();                     // asm int 0x21;

      _retl( _AL == 0 );
   #else
      SYSTEMTIME st;

      GetSystemTime( &st );
      st.wYear  = wYear;
      st.wMonth = wMonth;
      st.wDay   = wDay;
      _retl( SetSystemTime( &st ) );
   #endif
}
Hi Antonio,

I found the problem.

If i try your example before 11:00 pm runs ok
If i try your example after 11:00 pm returns wrong date.

Thanks.
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Post by Wanderson »

Antonio,

Dont work setdate() can i send one example to you?

Regards.
Post Reply