Feature requests
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?
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_numThe date numberdatetime_numthe date/time numbertime_numThe time numbertzThe time zoneIt would check the input
date_numanddatetime_numto 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_numargument which would also accept date/time values. And, perhaps the best would be to give both as options and have aguess_from_rangeargument which would guess if it were adate_numor adatetime_num.If the input were a date, then a
Dateobject would be the output. If the input were a date and a time or a date/time, then aPOSIXctobject would be the output. If the input were a time, then anhmsobject would be the output.What do you think?