New topic: 

Opinions please re - handling dates and times - sub-classing

<http://forums.realsoftware.com/viewtopic.php?t=47837>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        superjacent          Post subject: Opinions please re - handling 
dates and times - sub-classingPosted: Thu May 09, 2013 10:37 pm                 
                
Joined: Sat Oct 01, 2005 4:47 am
Posts: 111
Location: Melbourne, Australia                I've subclassed a TextField, 
naming it "base_Field_Date". As you can gather, it will be this control that is 
plonked on windows to manipulate date & time stuff.

In this sub-class I've added an integer property "DateType" and have set up 
constants 1,2 & 3 representing the datetype, 1 = Date and Time, 2 = Date only 
and 3 = Time only. I've also created three purpose functions each returning a 
boolean value. The function names are, IsDateAndTime(), IsDateOnly() and 
IsTimeOnly().  These functions are utilised when looping controls on a window 
and for date controls the correct date/time data is assigned to the control 
(and read back into the database).

Using this approach I have to handle, outside of the class, constants 
representing the date type relevant to the sub-class. Not a huge problem. In 
the sub-class I've defaulted the date/time data to be date and time display, so 
in debugging it should be obvious if I've forgotten to set the setting.

Another approach that has crossed my mind and appears simpler in 
implementation. I'm thinking of creating three sub-classed controls each based 
on the date type (Date and Time, Date only and Time only). I can do away with 
the functions checking for the date type as it will be a given the date type 
due to the type of sub-classed control.

I'm in the process of converting an existing Access database where there are 
100's of forms (windows). Most have date and time info, nearly all have audit 
type date/time stuff plus traditional date and time fields. So I want to deal 
with Date controls in the simplest way possible. 

After opinions please, for instance, are there any better ways? I'm all ears.

ps. For purpose database fields, the above sub-classed controls (which ever way 
I go) are sub-classed further to account for database type stuff (Table & Field 
names).      
_________________
Steve
rs2012 r2.1 Windows 7.      

    Last edited by superjacent on Fri May 10, 2013 7:48 am, edited 1 time in 
total.   
                             Top                Stretch          Post subject: 
Re: Opinions please re - handling dates and times - sub-clasPosted: Fri May 10, 
2013 7:32 am                       Real Software Engineer          
Joined: Tue Jul 14, 2009 4:33 pm
Posts: 146
Location: Jacksonville, FL                Why not put the three Public 
constants right onto your class and refer to them thusly:

if base_Field_Date1.DateType = base_Field_Date.DateAndTime then....

You could still have the three functions IsDateAndTime(), IsDate() and isTime()

Also, if you haven't tried this, Right-click on your control in the project 
list and select .... In the list of properties click the checkbox next to the 
DateType property (to make it visible in the Window Editor) and then to the 
right, you can define an enumeration for the property. Right there you can put 
human readable labels for each of the three possible values. Once you've done 
that, drag an instance out to a window and you'll see that users will have a 
menu to select from.      
_________________
Greg O'Lone
Software Engineer
Real Software  
                             Top                superjacent          Post 
subject: Re: Opinions please re - handling dates and times - sub-clasPosted: 
Fri May 10, 2013 8:27 am                                 
Joined: Sat Oct 01, 2005 4:47 am
Posts: 111
Location: Melbourne, Australia                Thanks Greg, your suggestion 
makes sense.

Stretch wrote:Also, if you haven't tried this, Right-click on your control in 
the project list and select .... In the list of properties click the checkbox 
next to the DateType property (to make it visible in the Window Editor) and 
then to the right, you can define an enumeration for the property. Right there 
you can put human readable labels for each of the three possible values. Once 
you've done that, drag an instance out to a window and you'll see that users 
will have a menu to select from.
I was aware of the property list behaviour but not familiar with the 
enumeration aspect. This will make things a little easier.      
_________________
Steve
rs2012 r2.1 Windows 7.  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to