Skip to content

Commit 837bdc5

Browse files
committed
adjusted comments
1 parent eea4cf5 commit 837bdc5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

R/utils.R

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,31 @@ has_star <- function(x) {
6363
# ### **Analysis**:
6464
# 1. **Excel Date Storage**:
6565
# - Excel does **not** store dates as the number of days since January 1, 1970. Instead:
66-
# - Excel stores dates as the number of days since **January 1, 1900** (for Windows systems) or **January 1, 1904** (for macOS systems).
67-
# - Excel also incorrectly assumes that 1900 was a leap year, which introduces an offset of 1 day for dates before March 1, 1900.
66+
# - Excel stores dates as the number of days since **January 1, 1900** (for Windows systems)
67+
# or **January 1, 1904** (for macOS systems).
68+
# - Excel also incorrectly assumes that 1900 was a leap year, which introduces an offset of
69+
# 1 day for dates before March 1, 1900.
6870
#
6971
# 2. **`read_excel` Behavior**:
70-
# - When using `readxl::read_excel`, Excel dates are typically read as numeric values representing the number of days since Excel's epoch (e.g., 1900 or 1904). These values are **not automatically converted to POSIXct** by `read_excel`. The user must manually convert them.
72+
# - When using `readxl::read_excel`, Excel dates are typically read as numeric values representing
73+
# the number of days since Excel's epoch (e.g., 1900 or 1904). These values are **not
74+
# automatically converted to POSIXct** by `read_excel`. The user must manually convert them.
7175
#
7276
# 3. **POSIXct Conversion**:
73-
# - The description mentions converting the number to a date using `as.POSIXct(as.integer(x))`. However:
74-
# - This assumes that the numeric value `x` is already in seconds since January 1, 1970, which is not the case for Excel dates.
75-
# - To convert Excel dates to R's `POSIXct`, you need to account for Excel's epoch (e.g., subtract the appropriate offset for 1900 or 1904).
77+
# - The description mentions converting the number to a date using `as.POSIXct(as.integer(x))`.
78+
# However:
79+
# - This assumes that the numeric value `x` is already in seconds since January 1, 1970, which
80+
# is not the case for Excel dates.
81+
# - To convert Excel dates to R's `POSIXct`, you need to account for Excel's epoch (e.g.,
82+
# subtract the appropriate offset for 1900 or 1904).
7683
#
7784
# 4. **Formatting**:
78-
# - The description correctly states that `format(as.POSIXct(x, tz=""), format="%Y-%m-%d")` can be used to format a `POSIXct` object as a string in the `YYYY-MM-DD` format.
85+
# - The description correctly states that `format(as.POSIXct(x, tz=""), format="%Y-%m-%d")`
86+
# can be used to format a `POSIXct` object as a string in the `YYYY-MM-DD` format.
7987
#
8088
# ### **Corrected Description**:
8189
# Here’s a revised and accurate version of the description:
82-
#
90+
#
8391
# Excel stores dates as numeric values representing the number of days since
8492
# January 1, 1900 (Windows) or January 1, 1904 (macOS). Note that Excel's 1900
8593
# date system incorrectly assumes 1900 was a leap year, which introduces a

0 commit comments

Comments
 (0)