Forum > General
[SOLVED] Date - very easy question, but "ugly" solution
Nicole:
What I want to do is:
DateTimePicker_ExitZeit.Time:=now;
Sure, this works very quickly.
If it is 15:29:25 - this value will be written into the TimePicker.
To avoid quick-reading-errors, I want the seconds to be gone.
To write
15:29:00
or 15:30:00
even better
( or 15:30 - may this work at all? it must stay a picker)
So how to do this:
I can get it by MinuteOf(now) and HourOf(now) as word types.
Then I figure them out and convert them back to time.
This is UGLY.
Has anybody a nicer way?
dsiders:
--- Quote from: Nicole on January 31, 2023, 07:36:43 pm ---What I want to do is:
DateTimePicker_ExitZeit.Time:=now;
Sure, this works very quickly.
If it is 15:29:25 - this value will be written into the TimePicker.
To avoid quick-reading-errors, I want the seconds to be gone.
To write
15:29:00
or 15:30:00
even better
( or 15:30 - may this work at all? it must stay a picker)
So how to do this:
I can get it by MinuteOf(now) and HourOf(now) as word types.
Then I figure them out and convert them back to time.
This is UGLY.
Has anybody a nicer way?
--- End quote ---
To zero out Seconds and Milliseconds:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---AWhen := Now;ADateTimePicker.Time := RecodeTime(AWhen, HourOf(AWhen), MinuteOf(AWhen), 0, 0);
To format the time on the date time picker:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ADateTimePicker.TimeDisplay := tdHM;
Kays:
--- Quote from: Nicole on January 31, 2023, 07:36:43 pm ---[…] Has anybody a nicer way?
--- End quote ---
Probably. How about this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---t := int(t * 1440) / 1440;
Nicole:
Thank you for the answers.
I would prefer a solution like
tdHM
- if I could!
I read, "invalid key" and am offer only display suggestions, which make sense only if the kind would be "date". Yes, the "kind" is set to dktime.
The wanted display is
HH:MM
wp:
I don't understand. This is working for me (It can be set in the Object Inspector as well):
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin DateTimePicker := TDateTimePicker.Create(self); with DateTimePicker do begin Kind := dtkTime; TimeDisplay := tdHM; Parent := Self; end;end;
Navigation
[0] Message Index
[#] Next page