Re: [jopendocument] time-values @ jOD 1.3

2015-01-04 Thread manfred . hanke
Hi Sylvain,

ILM wrote on 2014-02-03, 15:51:47 UTC+1:
>
> In the mean time, I added a work around in MutableCell, controlled with 
> setTimeValueMode().
> This will be available in the next release.
>

although a bit late, but I eventually upgraded to jOpenDocument-1.4rc2 today
and wanted to let you know that setting time-values works now (i.e. with 
your patch in jOpenDocument-1.4rc1) for me.

Thank you! :-)

Cheers,

Manfred

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"jOpenDocument" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jopendocument+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jopendocument] time-values @ jOD 1.3

2014-02-03 Thread Sylvain Cuaz

Le 29/01/2014 19:38, manfred.ha...@googlemail.com a écrit :



Hi,

I noticed that jOpenDocument 1.3 seems to store time values in an incorrect 
format.
For example, consider:
 SpreadSheet spreadSheet = SpreadSheet.create(1, 1, 1);
 Sheet sheet = spreadSheet.getFirstSheet();
 sheet.getCellAt(0, 0).setValue(
Calendar.getInstance(),
ODValueType.TIME,
true,
true
   );
 spreadSheet.saveAs(new File("TimeValueTest.ods"));
The problem is due toorg.jopendocument.dom.ODValueType.format(Object)returning
TimeUtils.timePartToDuration(cal).toString()that finally produces something like
   8:42:31 PM
 , which LibreOffice in turn interpretes as "12:00:00 
AM".
[I'm using version 3.5.7.2, Build ID: 350m1(Build:2).]
According to 
http://books.evc-cit.info/odbook/ch05.html#table-number-cells-section, an 
office:time-value should be stored in the form PThhHmmMss,S (where  is 
the fractional part of a second).


According to the standard, it should handle 0 (and even non zero by the way)
see https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office
and http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#duration


Replacingreturn TimeUtils.timePartToDuration(cal).toString()in
org.jopendocument.dom.ODValueType.format(Object)withDuration duration = 
TimeUtils.timePartToDuration(cal);
 double seconds = 
duration.getField(DatatypeConstants.SECONDS).doubleValue();
 return String.format("PT%02dH%02dM%07.4fS", duration.getHours(), duration.getMinutes(), 
seconds);gives
   8:42:31 PM
 , which seems to work correctly.


You can't just truncate durations, some other parts of LibreOffice (like user fields in meta.xml) do 
support the full syntax of durations.


You should file a bug in LibreOffice to ask for the full support of duration in 
cells.
In the mean time, I added a work around in MutableCell, controlled with setTimeValueMode(). This 
will be available in the next release.


Cheers,
Sylvain

--

--- 
You received this message because you are subscribed to the Google Groups "jOpenDocument" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to jopendocument+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.