Wrong time format imported from google sheets #676
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#676
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
There is an issue when trying to export google sheets document, which has time format
h":"mm" "am/pm
So for example -> 12:00 AM
It will automatically change AM PM to a1/p1 or a2/p2, a3/p3 or a4/p4 .
Not sure if it's related to the google sheets or the library.
If time is entered as a plain text - without the time format, then it works as expected, but, as soon as, time format is applied it gives back this strange a1/p1, e.t.c. instead of AM or PM.
First, thanks for reporting :) This is ultimately a bug in google sheets but we should try to replicate Excel's repair process.
What is the correct interpretation of the format?
The number format grammar is laid out in the description of the XLS Format Record. The relevant comment regards the interpretation of AM/PM:
The key point is that the correct specification is
AM/PM
orA/P
--a/p
andam/pm
are not to be interpreted as the midday marker.How is Excel magically fixing this?
My best guess is that Excel automagically converts
am/pm
toAM/PM
. I checked a few older versions of Excel and they make the same corrections.Why is SheetJS giving a different result?
The SSF Formatter is designed to largely conform to the specs. Based on the grammar, the letter "a" is to be interpreted as a bare letter
a
, "p" is to be interpreted as a bare letterp
, andm
is to be interpreted as the month. If you take 12:00 AM, the default assumed date is January 1 1900, hence1
for them
. You can play around with the SSF Demo to see the behavior in action.To prove that this is largely consistent with Excel, change the number format to
h:mm am/p
(no trailing "m") and you will see the samea1/p
.Fix
That is easily fixed -- since neither
a
norp
are significant on their own, theA
case can be modified to includea
. If that's of interest to you, we'd accept a PR in the dependency and then rebuild this library.