You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/utils.R
+16-8Lines changed: 16 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -63,23 +63,31 @@ has_star <- function(x) {
63
63
# ### **Analysis**:
64
64
# 1. **Excel Date Storage**:
65
65
# - 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.
68
70
#
69
71
# 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.
71
75
#
72
76
# 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).
76
83
#
77
84
# 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.
79
87
#
80
88
# ### **Corrected Description**:
81
89
# Here’s a revised and accurate version of the description:
82
-
#
90
+
#
83
91
# Excel stores dates as numeric values representing the number of days since
84
92
# January 1, 1900 (Windows) or January 1, 1904 (macOS). Note that Excel's 1900
85
93
# date system incorrectly assumes 1900 was a leap year, which introduces a
0 commit comments