<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - The Time Control no longer supports 12-hour times through TimeFormat"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=135287">135287</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The Time Control no longer supports 12-hour times through TimeFormat
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>6.2.5.2 release
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86-64 (AMD64)
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>BASIC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>atemple@rogers.com
</td>
</tr></table>
<p>
<div>
<pre>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 <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED NOTABUG - Date Controls changed in Basic"
href="show_bug.cgi?id=68751">Bug 68751</a> - 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="<a href="http://openoffice.org/2000/dialog">http://openoffice.org/2000/dialog</a>"
xmlns:script="<a href="http://openoffice.org/2000/script">http://openoffice.org/2000/script</a>" 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></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>