Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » Enter time as duration
Enter time as duration [message #11249] Tue, 28 August 2007 20:10 Go to next message
guido is currently offline  guido
Messages: 169
Registered: April 2006
Experienced Member
Hi,

I need a widget for entering things like how long a certain task is expected to take in hours and minutes. Can EditTime be fudged to do that?
Someone here done that Smile

Guido
Re: Enter time as duration [message #11256 is a reply to message #11249] Wed, 29 August 2007 09:40 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
EditTime won't do it because it only accepts times <= 12 hours. You need to define your own convert function and edit control:
typedef EditMinMax<Time, ConvertDuration>            EditDur;

You should still be able to use the Time class, providing durations are < 256 hours.
Re: Enter time as duration [message #11260 is a reply to message #11256] Wed, 29 August 2007 10:11 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Actually, it turns out this is a bit of a cock-up (IMO).

Basically what happens is that the EditTime control is really an EditTimeANDDate control, and always expects a valid date to be entered first.

For example, with date format mdy:
23:00 - not valid
11:01:2007 - valid
11:40:00 - not valid
11:00:2007 - not valid
11:34:1900 - valid
11:34:1900 23:30:01 - valid

So currently Upp has a 2 Date only controls and a Date AND Time control, but no Time only control. Sad
Re: Enter time as duration [message #11281 is a reply to message #11260] Thu, 30 August 2007 18:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11844
Registered: November 2005
Ultimate Member
I would just (as noted in abother thread) created Convert working with number of seconds.... (maybe even as double number to cover sub-second times).

Mirek
Re: Enter time as duration [message #14892 is a reply to message #11281] Wed, 19 March 2008 00:16 Go to previous messageGo to next message
jlfranks is currently offline  jlfranks
Messages: 55
Registered: May 2007
Location: Houston, TX, USA
Member
Well, I think Duration is a general case and should be included
in Upp.

I just ran into this problem, i.e., where Time is really Time&Date. I need a Duration type.

Imagine a case whereby process control batch has many different
timed durations and we use Upp to present this to the operator.

Duration should be a type included in Upp. Also, it is not just
a new typedef as was mentioned.

Value type must comprehend the new type Dur or Duration (depending on how it is named). There are guards that check for null and empty, and it switches on the test depending on the
Type and applies the right operation for that Type.

Not as simple as just a new typedef as stated earlier:
typedef EditMinMax<Time, ConvertDuration> EditDur;

More is involved.

--jlf
Re: Enter time as duration [message #15005 is a reply to message #14892] Tue, 25 March 2008 12:05 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
You shouldn't need to modify UppSrc, all you need is:
- A Duration class with operators to/from int, operators >, < etc. (just convert to int and compare)
- A custom Convert class/Edit ctrl
Since most of this is copying from existing code it really isn't much work, see attached. ToInt/FromInt could probably be improved, and you may wish to add Null support.

jlfranks


Not as simple as just a new typedef as stated earlier:
typedef EditMinMax<Time, ConvertDuration> EditDur;

More is involved.


Smile I did say that you had to define a new Convert class, which is where all the work is done. It's possible, but perhaps not the best solution.
  • Attachment: Duration.h
    (Size: 3.52KB, Downloaded 555 times)

[Updated on: Tue, 25 March 2008 12:50]

Report message to a moderator

Previous Topic: DocEdit call RemoveLines make Assertion failed.
Next Topic: editing selection in doc edit
Goto Forum:
  


Current Time: Thu Apr 25 12:36:13 CEST 2019

Total time taken to generate the page: 0.00700 seconds