B4A Library EditDate Library

Component to simplify date input
B4X:
' create the component
Dim edit_date1 As xnEditDate
edit_date1.Initialize("edit1_date")
Activity.AddView ( edit_date1 ,  0dip , 105dip ,  180dip , 40dip )


' setting and getting the value
Dim now As Long
now = DateTime.now

edit_date1.DateAsLong = now

now = edit_date1.DateAsLong
Msgbox ( "The date is: " & DateTime.Date(now) & CRLF & "The time is: " & DateTime.Time(now) , "" )

edit_date1.DateAsSql = "20120514"

now = edit_date1.DateAsLong
Msgbox ( "The date is: " & DateTime.Date(now) & CRLF & "The time is: " & DateTime.Time(now) , "" )

Added change event
B4X:
Sub edit_date1_change
MsgBox ( edit_date1.DateAsSql , "Change" )
End Sub
 

Attachments

  • xnObjects145.zip
    29 KB · Views: 605
  • xnObjects150.zip
    36.4 KB · Views: 841
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
great job stefanobusetto!! :icon_clap:
 

alfcen

Well-Known Member
Licensed User
Longtime User
Brilliant, Stefano!

A [Today] button between [Set] and [Cancel] would crown your library
(if that is not Fabio's meaning of "event date clear").

A cosmetic issue: Longer dates, such as "Wednesday, September 19, 2012"
cause a line break in the dialog. I tried 'EditDate.Format_display' without effect. Perhaps the default format "Wed, Sep 19, 2012" would suffice.

A minor issue, the icon shows a clock symbol whereas a calendar symbol
might be expected.

Ciao a tutti!
 

stefanobusetto

Active Member
Licensed User
Longtime User
What i'd like very much is having 4 buttons ( set, cancel, clear and today).
I'd like also to be able to select which of them should be visible and which not.
This is not a problem anyway.
To select a date now i use DatePickerDialog.
The DatePickerDialog does not allow additional buttons as far as i've seen.
I've seen there are also other date selection dialogs (DateSlider for example) and i'm going to start the tests.
:)
 

jrat

Member
Licensed User
Longtime User
What events at EditDate object?
it is necessary call procedure at date change
 

stefanobusetto

Active Member
Licensed User
Longtime User
Thanks. I've thought about it. But i've not planned yet. If you want i can share the sources. :)
 

ThePuiu

Active Member
Licensed User
Longtime User
Unfortunately, I don't have the knowledge needed to create a library ... but I solved the problem by doing two different activity: one for date and other for time (with the same design as your library!)
 
Top