[Libreoffice-bugs] [Bug 135287] New: The Time Control no longer supports 12-hour times through TimeFormat

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Jul 29 18:47:38 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=135287

            Bug ID: 135287
           Summary: The Time Control no longer supports 12-hour times
                    through TimeFormat
           Product: LibreOffice
           Version: 6.2.5.2 release
          Hardware: x86-64 (AMD64)
                OS: Windows (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: atemple at rogers.com

The Problem: The Time Control no longer supports 12-hour times, even if you set
TimeFormat to 2 (12 Hour - Short) through BASIC or directly in the dialog
itself. (i.e. making that the default format.)

What Actually Happens: Even though the Time Control accepts changes to the
TimeFormat value, it does not act on that change. It always uses 24 Hour time
-- it never displays am/pm at all. If you use the Up Arrow, with the cursor in
the hour part of the Time Control, you'll see that after 12:00 it goes to
13:00, 14:00, etc. A user can ignore what he sees in the Time Control display,
and type out a full am/pm time such as "1:30 pm" and the Time Control does
accept that and converts it to the correct 24 Hour time, namely 13:30.

To replicate this behavior, I've supplied a small BASIC sub, GetMyTime(), that
accesses a very simple dialog that has only a Time Control (TimeField1) and an
OK and Cancel button. (You can make this yourself, or you can import the dialog
file I exported. See below. I call this from Writer.)

In my Sub, you'll see the line:

   If isNumeric(oCtl.getTime()) Then

Around version 4.1.1.2 of Libre, they made the switch to using a structure for
the Time instead of the Long that has been used since the early days with
OpenOffice. (See Bug 68751 - Date Controls changed in Basic.) If I were to make
a guess, I'd look at the point when this change was made to see if that's where
the new problem with TimeFormat was created.

This is a particularly nasty problem for me. I'm developing a Libre Template
that creates a Diary / Day Planner for Writer, and the Day Planner's
Appointment Time column uses either 12 or 24 hour time format. But as this is
initially being created only for English-speaking countries, 12 Hour am/pm time
is really the only option that users will actually want. As it is, I'll have to
add some code to test for Libre version and to use a MSgBox() to explain to
users with the inoperable TimeFormat, that they'll just have to type in the
full am/pm time that they want. I hope this can be fixed soon.

Last Thought: The code and dialog below work properly in OpenOffice 4.1.6.


Sub GetMyTime()

Dim oCtl, Dlg As Object
Dim LTime As Long
Dim PlannerHour, PlannerMinutes As Integer

   DialogLibraries.LoadLibrary("Standard")
   Dlg = CreateUnoDialog(DialogLibraries.Standard.TimeDialog)

   oCtl = Dlg.getControl("TimeField1") ' get the TimeField control
   oCtl.Model.TimeFormat = 2
   MsgBox("TimeFormat is:" & oCtl.Model.TimeFormat)

StartOver:

   ' Here we would want to set up those things as required

   If Dlg.Execute() = 0 Then ' Now we can execute the Dialog and allow the user
to change things
      goto Leave ' User Cancelled the Dialog
   End If

   ' Get the Time the user has chosen
   oCtl = Dlg.getControl("TimeField1") ' get the TimeField control
   If oCtl.isEmpty() Then
      MsgBox("You must provide a Time for the Appointment", 16, "GetMyTime")
      goto StartOver
   End If

   If isNumeric(oCtl.getTime()) Then
      LTime = oCtl.getTime()  ' OpenOffice and early Libre stores Time as a
Long
      PlannerHour = LTime / 1000000 ' The hour part of the long time
      PlannerMinutes = LTime / 10000 MOD 100 '  The minute part of the long
time
   Else
      PlannerHour = oCtl.Time.Hours ' Later Libre stores time as a structure
      PlannerMinutes = oCtl.Time.Minutes
   End If

   MsgBox("Time is: " & PlannerHour & ":" & PlannerMinutes)

    Leave:
      Dlg.dispose()

End Sub




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN"
"dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog"
xmlns:script="http://openoffice.org/2000/script" dlg:id="TimeDialog"
dlg:left="136" dlg:top="106" dlg:width="62" dlg:height="69"
dlg:closeable="true" dlg:moveable="true">
 <dlg:styles>
  <dlg:style dlg:style-id="0" dlg:font-height="12"/>
  <dlg:style dlg:style-id="1" dlg:font-height="10"/>
 </dlg:styles>
 <dlg:bulletinboard>
  <dlg:text dlg:style-id="0" dlg:id="Label1" dlg:tab-index="0" dlg:left="6"
dlg:top="2" dlg:width="21" dlg:height="15" dlg:value="Time:"/>
  <dlg:timefield dlg:id="TimeField1" dlg:tab-index="1" dlg:left="6"
dlg:top="18" dlg:width="49" dlg:height="19" dlg:printable="false" dlg:tag="This
is some additionla information" dlg:help-text="Appointment Time"
dlg:hide-inactive-selection="false" dlg:strict-format="true"
dlg:time-format="12h_short" dlg:value="9000000"/>
  <dlg:button dlg:style-id="1" dlg:id="CommandButton1" dlg:tab-index="2"
dlg:left="35" dlg:top="44" dlg:width="20" dlg:height="15" dlg:value="OK"
dlg:button-type="ok"/>
  <dlg:button dlg:id="CommandButton2" dlg:tab-index="3" dlg:left="7"
dlg:top="44" dlg:width="24" dlg:height="15" dlg:value="Cancel"
dlg:button-type="cancel"/>
 </dlg:bulletinboard>
</dlg:window>

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200729/b52967e1/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list