time format problem

Questions, tips and tricks and techniques for scripting in Servoy

time format problem

Postby Harjo » Thu Jan 08, 2009 12:37 pm

Hi there,

I want to make typing times, easier for our customers,

I had a timefield, with this format: HH:mm
now they always have to type the ':' which is not handy, so I thought I try this format: HH:mm|HHmm

but now, this only works for 1000 and higher (which becomes 10:00)
if I type: 830, I want it to become: 8:30, Servoy makes it: 11:00 :-(

so I thought I make the format: HH:mm|Hmm
and than it works for 830 (servoy makes it 8:30) but I does not work anymore for everything higher than 1000.
for instance if I fill in: 1010, servoy makes it: 01:10 :-(

anyone seen this or fixed this???

another problem I have seen, as soon as I use a format: like this: HH:mm|HHmm
my custom valuelist on the same field (editable combobox) is not working anymore, it is empty

Here is my customer valuelist:
00:00
00:15
00:30
00:45
01:00
01:15
01:30
01:45
02:00
etc..
etc..

I have tried to make the valuelist like this:
0000
0015
0030
0045
0100
0115
0130
0145
0200
etc..
etc..

but that does not work either....
the strange this is that as soon as I use on 1 field this format: HH:mm|HHmm the valuelist does not work anymore, on any other timefield, (which has still a format: HH:mm)
I'm using Servoy 3.5.7_01 right now and Java 6 u11 on Windows XP

Hope someone can help me out here
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: time format problem

Postby IT2Be » Thu Jan 08, 2009 12:47 pm

What happens when you do this: 'HH:mm|' (without quotes)
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: time format problem

Postby Harjo » Thu Jan 08, 2009 1:00 pm

nothing,

than I can't type: 1000 I MUST type the ':' so like this: 10:00
and the valuelist is also still broken.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: time format problem

Postby pbakker » Thu Jan 08, 2009 2:14 pm

Maybe the converter format is a solution for you?

See: viewtopic.php?f=22&t=11684

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: time format problem

Postby Harjo » Thu Jan 08, 2009 2:22 pm

oke, i will go further there, for the inut syntax, but that does not solve my issue, why the valuelist breaks, when I use a format: HH:mm|HHmm


thanks.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: time format problem

Postby jcompagner » Wed Apr 29, 2009 12:19 pm

that your valuelist doesnt work for HHmm or Hmm is pretty logical

for Hmm the 1100 cant be parsed because there is 1 char to much
for HHmm the 830 can be parsed but parsing happens from the front not the back
so first H maps on 8, second H on 3 and m on 0 and then the last m on nothing (so you are saying 8300)
then you get those auto conversions and you get things like 11:00 or what ever the rollover hours are.

You can do what you want with the global converter on that time field make these 2 global methods:


Code: Select all
function fromObject(object)
{
   if (object.length == 3)
   {
      return utils.dateFormat(object,"Hmm");
   }
   else if (object.length == 4)
   {
      return utils.dateFormat(object,"HHmm");
   }
   else
   {
      throw "Not supported input " + object;
   }
   return object;
}

funnction toObject(object)
{
   return utils.dateFormat(object,"HHmm");
}



then place a field and set the format to converter
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 47 guests