Bug? DateTime.Time ignores TimeFormat when in 24 hr mode

Discussion in 'iOS Bugs & Wishlist' started by Jack Cole, Oct 6, 2019.

  1. Jack Cole

    Jack Cole Active Member Licensed User

    It seems there is a bug that happens on iOS when the phone is set to 24-hour mode. It seems to ignore the TimeFormat when you try to get the time string from the ticks value.

    Dim TimeVal=DateTime.DateTimeParse(DateTime.Date(DateTime.Now),"07:00"As Long
    DateTime.TimeFormat="hh:mm a"
    Log("Converted time = "&DateTime.Time(TimeVal))
    Here is the log output:
    Converted time = 07:00

    Turn off 24-hour mode on the phone and you get:
    Converted time = 07:00 AM

    I think the result should be the same regardless of the time mode the phone is in. Am I missing something or is this a bug?
  2. stevel05

    stevel05 Expert Licensed User

    As a guess I would think that 19:00 would return 07:00 PM, so you can tell the difference when not in 24 Hour mode. But I can't test it.
  3. Jack Cole

    Jack Cole Active Member Licensed User

    Unfortunately, it returns 19:00.
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is fixed for the next update. The locale of the internal date and time formatters will be explicitly set to en_US_POSIX.

    As a workaround call this sub when the program starts and pass "en_US_POSIX":
    Sub SetDateTimeLocale (locale As String)
    Dim loc As NativeObject
       loc = loc.Initialize(
    Dim no As NativeObject = DateTime
    "dateFormat").SetField("locale", loc)
    "timeFormat").SetField("locale", loc)
    End Sub
    Jack Cole likes this.
  5. Jack Cole

    Jack Cole Active Member Licensed User

    Perfect. That got it working. Thank you.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice