Bug 157933 - phone numbers FORMATTING
Summary: phone numbers FORMATTING
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.5.0.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-26 12:24 UTC by mejames1974
Modified: 2023-10-26 13:57 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mejames1974 2023-10-26 12:24:40 UTC
Description:
A phone number format in calc would keep the leading zero and have a user specified alignment. 

Actual Results:
leading zero removed

Expected Results:
not removed


Reproducible: Always


User Profile Reset: No

Additional Info:
none
Comment 1 Mike Kaganski 2023-10-26 13:20:51 UTC
Phone "numbers" are not numbers (amounts used to calculate). Thus, the cells where phone numbers (and other identifiers, possibly resembling numbers) are stored, must be pre-formatted as text; or the identifiers must be entered with leading apostrophe ('). Importing from CSV must also set the data type for the columns with such identifiers as text.

To emphasize the importance, and show that it is not just a cosmetic issue or a nitpicking: for identifiers longer than 15 digits, it is simply impossible to store all the digits in a numeric data; so unless one properly imports/enters these digits as text, an identifier like 1234567890123456789 will be rounded to 1234567890123460000, loosing the last digits irreversibly.
Comment 2 Eike Rathke 2023-10-26 13:57:49 UTC
Numeric values _never_ preserve a leading zero and the maximum representable integer value is 9007199254740991 (2^53-1). As Mike said, either pre-format the cell with the Text format before entering the value, or in a General formatted cell enter the phone number as text string by prepending a leading ' apostrophe, like '012-345-678901

However, to display a numeric value such, you could use a format code like

[<=9999999]###-####;[<=999999999]"0"##-###-####;"0"##-###-###-####

See also https://help.libreoffice.org/7.6/en-GB/text/shared/01/05020301.html?&DbPAR=CALC

That would display

     4567890 =>         456-7890
    34567890 =>      03-456-7890
   234567890 =>     023-456-7890
  1234567890 =>   0-123-456-7890
 91234567890 =>  09-123-456-7890
891234567890 => 089-123-456-7890

Note that phone number formats differ between locales, so adjust the format code to your needs. Also, it is not possible to display the same number different depending on the net provider or area code, so differentiating between 012-3456789 and 0123-456789 is not possible. The only way to do it properly is using text instead of numeric.