After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 490419 - Date constants change values when moved between sheets with different date convensions
Date constants change values when moved between sheets with different date co...
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export other
git master
Other All
: Normal normal
: ---
Assigned To: Morten Welinder
Jody Goldberg
: 525323 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-10-26 07:26 UTC by Daniel Vianna
Modified: 2008-04-10 18:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
original file with date (2.54 KB, application/octet-stream)
2007-10-26 07:27 UTC, Daniel Vianna
  Details
destination file with wrong date pasted into it (1.98 KB, application/octet-stream)
2007-10-26 07:28 UTC, Daniel Vianna
  Details
Patch for the brave (10.48 KB, patch)
2008-04-09 17:42 UTC, Morten Welinder
none Details | Review

Description Daniel Vianna 2007-10-26 07:26:00 UTC
In gnumeric-1.7.13, I have a date-formatted cell which when pasted into a new file has its value changed from 9/28/2011 to 9/27/2007. If I copy/paste it back to the initial file, then it comes back to the original value.

Sample files attached...
Comment 1 Daniel Vianna 2007-10-26 07:27:37 UTC
Created attachment 97888 [details]
original file with date
Comment 2 Daniel Vianna 2007-10-26 07:28:14 UTC
Created attachment 97889 [details]
destination file with wrong date pasted into it
Comment 3 Jon Kåre Hellan 2007-10-26 12:41:06 UTC
The source uses date convention 1904, like Excel does on the Mac. An importer, probably Excel, must have chosen it.

Certainly confusing for the user. But since there is no fundamental distinction between dates and numbers in spreadsheets, a workaround may lead to even more confusion.
Comment 4 Morten Welinder 2007-10-26 13:22:28 UTC
The source is in 1904-base, but that is not the real problem here, I think.

We are treating this as a plain number.  I think that is because the cell
does not have a format, only the number in the cell does.  If we format
as a date, then things actually paste correctly.  (Which, pick your poison,
means that the value changes by 4*365, give or take one.)
Comment 5 Morten Welinder 2007-10-27 02:12:53 UTC
I have fixed a close cousin of this problem: text targets (such as when
pasting into Emacs) now take the value format into account.
Comment 6 Morten Welinder 2007-10-27 02:36:01 UTC
I have now also added the date convention to the clipboard xml.  That
is certainly the right thing to do, but I am not sure how to proceed
from here.

We could refuse to paste into a workbook with different date convention,
or at the very least warn when that happens.  That should not be often.

We could also detect cells with date formats in them and have the
receiving gnumeric add an offset for those cells if the date formats
are different.

Ideas welcome.
Comment 7 Daniel Vianna 2008-04-09 06:08:03 UTC
I'm pasting date-formatted data from one file into another, and it still changes the date.

A way to deal with that issue would be to, when pasting date-formatted data from clipboard, to ask the user to choose which convention gives the correct result. It seems pretty easy to detect an error when a 2007 date is pasted as 2011...

Another option would be to make the user choose the date convention in the cell format widget. That's the obvious place to look for it. I would like to be able to fix the date convention after pasting, if I find that it is displaying the wrong date.
Comment 8 Daniel Vianna 2008-04-09 06:40:10 UTC
Or maybe you could reproduce the same steps I take manually to validate the result of the paste. What I'm doing now, so I paste correctly:

1) copy from one gnumeric file, paste in a text editor (leafpad);
2) copy from leafpad, paste to another gnumeric file;
3) gnumeric opens the import widget, and I select date, and the format I want;
4) the paste is successful.

If you include the convention in the clipboard data, then gnumeric should take into account the convention of the file it is pasting to, right? And convert the data accordingly. If more validation is required when gnumeric pastes that data back, it could check if the result to be displayed resembles what would be displayed in the source convention format.

Else, just paste what it looks like and ask the user to supply the cell data format.
Comment 9 Morten Welinder 2008-04-09 11:42:34 UTC
*** Bug 525323 has been marked as a duplicate of this bug. ***
Comment 10 Morten Welinder 2008-04-09 17:42:20 UTC
Created attachment 108942 [details] [review]
Patch for the brave
Comment 11 Morten Welinder 2008-04-09 23:29:27 UTC
The src/wbc-gtk-actions.c part is irrelevant for this bug.

Comment 12 Daniel Vianna 2008-04-10 07:25:14 UTC
Awesome! The patch works here. But I think you made two typos:

"Copying between sheet with different date convensions
It is possible that some dates could be be copied
correctly."

You probably meant "conventions" and "incorrectly", right? Because I can just be glad if the dates are copied correctly. No need to warn me if it works as expected! ;-)
Comment 13 Daniel Vianna 2008-04-10 07:26:14 UTC
Another typo: it should read "sheets" (plural).
Comment 14 Morten Welinder 2008-04-10 14:14:29 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
Comment 15 sum1 2008-04-10 18:04:23 UTC
commands.c now has: "It is possible that some dates could be be copied" (note the double "be").
Comment 16 Morten Welinder 2008-04-10 18:54:00 UTC
Fixed.