Convert old Date to Xojo.Core.Date

  1. ‹ Older
  2. 2 years ago

    Djamel A

    25 Jul 2018 Oran (Algeria)

    @Björn Eiacute;ksson I am not sure what you are asking you get notify in the event when the value changes and you there notify the rest of your application and variables of the change.

    If you for any reason want to read the value at random time then you just read the controls DateValue property.

    Basically same as any other control works

    Unfortunately i can not show any example code TimeCtrl and DateCtrl (plugin) are not exported with the project.
    I give an example :
    I wrote Method to draw analogical clock, i want to move the needles shows.
    when i modify "hour or minutes" the needles shows must move imidiately ... , it means that the time inside my draw method changes when increasing or decreasing the hours or minutes in the Time Picker (TimeCtrl).

  3. Björn E

    26 Jul 2018 Pre-Release Testers, Xojo Pro Iceland

    It is just like any other Xojo control, your get Value changed event, you Set your stored variable or property, you call invalidate on your "needles" drawing control and it draws what you have stored in your property. => Happens immediately

  4. Djamel A

    26 Jul 2018 Oran (Algeria)

    @Björn Eiacute;ksson It is just like any other Xojo control, your get Value changed event, you Set your stored variable or property, you call invalidate on your "needles" drawing control and it draws what you have stored in your property. => Happens immediately

    Understood, it happens. The methods called for drawing are also Invalidate.
    Problem that the draw is not refreshed, overlapping , it means that the program keep the elapsed time in memory ...
    The drawing is moving properly no overlapping when time is introduced by TextField "hour", Textfield "minutes", etc ...

  5. Björn E

    26 Jul 2018 Pre-Release Testers, Xojo Pro Iceland

    Ah I think I know what you mean

    There is delay in the date and time control entry......since else you could not enter some values. It needs to delay while you are entering to give you time to enter valid number before applying validations. So you have maybe half a second delay.

    Before that delay was put there the user experience was sometimes horrible. Like if min date was 1.1.2001, and you start to enter 2001, then you type 2, and get validation and the year 2 would be to low. Input delay handles such so you can enter 2001 before validation happens. (Pretty standard practice for controls like this one)

  6. Djamel A

    27 Jul 2018 Oran (Algeria)

    @Björn Eiacute;ksson Ah I think I know what you mean

    There is delay in the date and time control entry......since else you could not enter some values. It needs to delay while you are entering to give you time to enter valid number before applying validations. So you have maybe half a second delay.

    Before that delay was put there the user experience was sometimes horrible. Like if min date was 1.1.2001, and you start to enter 2001, then you type 2, and get validation and the year 2 would be to low. Input delay handles such so you can enter 2001 before validation happens. (Pretty standard practice for controls like this one)

    Unfortunately i have not found solution, The Date Time Picker((EinHugur Plugin) become uncontrollable, focus on the hour or minute does not respond, only the second change (increase or decrease) slowly ...
    Entering the time value by textfield run properly but ... !

  7. 7 weeks ago

    Josh H

    Jan 10 Pre-Release Testers, Xojo Pro

    Public Function SecondsSince1904KSW(Extends d As DateTime) as Double
    Return d.SecondsFrom1970+kSecondsBetween1904And1970+timeZone.Current.SecondsFromGMT
    End Function

    Public Function NewDateTimeFromLegacyDateTotalSeconds(d As Double) as DateTime
    Return New DateTime(d-kSecondsBetween1904And1970-TimeZone.Current.SecondsFromGMT,TimeZone.Current)
    End Function

    Public Const kSecondsBetween1904And1970 as Number = 2082844800

    Sub Open() Handles Open
    Dim d As New Date
    Dim dNew As New DateTime(d)

    Dim dTS, dTS2 As Double
    dTS = d.TotalSeconds
    dTS2 = dNew.SecondsSince1904KSW

    Dim dTrial As DateTime = NewDateTimeFromLegacyDateTotalSeconds(dTS2)
    break
    End Sub

  8. Djamel A

    Jan 11 Oran (Algeria)

    Hi Josh,
    i am still using 2015r1, DateTime() works only since 2019r2.
    thank you

or Sign Up to reply!