home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
POINT Software Programming
/
PPROG1.ISO
/
c
/
actlib11
/
tvtools
/
indate.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-02
|
2KB
|
74 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#define Uses_TStreamable
#define Uses_MsgBox
#define Uses_TInputDate
#include "tvtools.h"
__link( RInputLine )
#include <string.h>
#include <stdio.h>
#include <values.h>
#include <stdlib.h>
#include <strstream.h>
#include "date.h"
// TInputDate
const char * const TInputDate::name = "TInputDate";
TInputDate::TInputDate( const TRect& bounds )
:TInputRegExp( bounds, 7, "0-9" )
{
}
TInputDate::TInputDate( int x, int y )
:TInputRegExp( x, y, 7, "0-9" )
{
}
Boolean TInputDate::valid( ushort command )
{
switch( command )
{
case cmReleasedFocus: return True;
case cmQuit :
case cmClose:
case cmOK :
/*
if ( ! *data ) { struct date today ;
getdate( &today ) ; // Get current date
char buffer[10];
sprintf( buffer, "%02d%02d%02d",
today.da_year - 1900, today.da_mon + 1, today.da_day
);
setData( buffer );
}
*/
unsigned long yymmdd = 0;
sscanf( data , "%lu" , &yymmdd );
#pragma warn -sig
int year = yymmdd / 10000;
int month = (yymmdd % 10000) / 100;
int day = yymmdd % 100;
#pragma warn .sig
if ( ! isdatevalid(day, month, year) )
{
select();
messageBox( " \n\03Invalid date !", mfError | mfOKButton );
selectAll( True );
return False;
}
break;
}
return TInputRegExp::valid( command );
}