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
As an analogy to excel_numeric_to_date(), I think that a sas_numeric_to_date() function could help. SAS formats its dates in a vaguely similar way, but SAS dates and date/times start from 1960-01-01 and times are seconds since midnight on the current day (https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm).
I think that the function would be relatively simple with the following arguments:
date_num The date number
datetime_num the date/time number
time_num The time number
tz The time zone
It would check the input date_num and datetime_num to confirm that it is likely the correct type. The ranges are very different, so it seems like it should be okay (the date 3000-01-01 would only be January 5, 1960 if it were accidentally given in the wrong format). Another option would be to have a single date_num argument which would also accept date/time values. And, perhaps the best would be to give both as options and have a guess_from_range argument which would guess if it were a date_num or a datetime_num.
If the input were a date, then a Date object would be the output. If the input were a date and a time or a date/time, then a POSIXct object would be the output. If the input were a time, then an hms object would be the output.
What do you think?
The text was updated successfully, but these errors were encountered:
That sounds good to me overall. Thanks for linking to the SAS spec. What you propose for inputs seems thorough and appropriate, allowing for date, OR time, OR date and time, OR date-time. The guessing sounds reasonable to me, as long as it allows for the option of specifying which it is (i.e., don't guess) - and if you're up for writing the guesser 😁
Feature requests
As an analogy to
excel_numeric_to_date()
, I think that asas_numeric_to_date()
function could help. SAS formats its dates in a vaguely similar way, but SAS dates and date/times start from 1960-01-01 and times are seconds since midnight on the current day (https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm).I think that the function would be relatively simple with the following arguments:
date_num
The date numberdatetime_num
the date/time numbertime_num
The time numbertz
The time zoneIt would check the input
date_num
anddatetime_num
to confirm that it is likely the correct type. The ranges are very different, so it seems like it should be okay (the date 3000-01-01 would only be January 5, 1960 if it were accidentally given in the wrong format). Another option would be to have a singledate_num
argument which would also accept date/time values. And, perhaps the best would be to give both as options and have aguess_from_range
argument which would guess if it were adate_num
or adatetime_num
.If the input were a date, then a
Date
object would be the output. If the input were a date and a time or a date/time, then aPOSIXct
object would be the output. If the input were a time, then anhms
object would be the output.What do you think?
The text was updated successfully, but these errors were encountered: