IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Improve the date/time keyboard in the calculator #8884

Closed rdstern closed 1 month ago

rdstern commented 4 months ago

@Fidel365 this is again improvements to the keyboard plus the addition of tooltips. It is now ready for you to attack!

Here is the current keyboard:

image

In addition: a) Add an as.date key in 2nd place on the top row. It produces lubridate::as_date(x = ), (So same as current datetime key, for just date.) (The year key moves to the 4th row?) b) Change the name on current datetime key to as.datetime. c) Addas.time key, at the end of the new second row, giving ymd::as_hms from the hms package d) Add 3 new keys on the new 3rd row, to give date-time variables, namely ymd.hms, ymd.hm, ymd.h keys giving lubridate::ymd_hms( ) etc e) In leap key (leap_year function) Change x= to date= f) Add a new month key on the 4th row.

So the keys are now: date, as.date, as.datetime, time ymd, dmy, mdy, as.time ymd.hms, ymd.hm, ymd.h, leap year, quarter, month, day yday, wday, d_in_m, am pm, hour, min, sec

The tooltips: date: Get the date part of a date-time variable as.date: converts a character or numeric variable into a date. For example as_date(30) or as_date("19700131") or as.date("1970.jan-31") each give 1970-01-31 as.datetime: converts a character or numeric variable into a date-time variable. For example as_datetime(30) gives 1970-01-01 00:00:30 UTC time: converts seconds, minutes, hours into a time variable. For example hms(185) gives 00:03:05, hms(25, 64) gives 01:04:25

ymd: makes a date variable from various character or numeric formats in year-month-day order. For example ymd(19840512) gives 1984-05-12 dmy: makes a date variable from various formats in day-month-year order. For example dmy(12051984) gives 1984-05-12 mdy: makes a date variable for mdy order. For example mdy(5121984) gives 1984-05-12. (Note alternatives of myd, ydm and dym) as.time: makes a time variable from numeic or character variable. For example: as_hms(185) gives 00:03:05, as_hms("14:55:10) gives 14:55:10

ymd.hms: make a date-time variable from various character or numeric formats ymd.hm: make a date-time variable from various formats. For example ymd_hm(202406161201) gives 2024-06-16 12:01:00 UTC ymd.h: make a date-time variable from various formats. For example ymd_h("2024.6:16,12") gives "2024-06-16 12:00:00 UTC" leap True if date is from a leap year and FALSE otherwise. For example leap(1984-05-12) is TRUE

year: extract year from date or date-time. For example year("1984-5-12") gives 1984 quarter: 3-month period of the year from a date or date-time variable. For example quarter("1984-05-12) gives 2 month: extract month from a date or date-time variable.
day: extract day in month from date or date-time. For example day("1984-5-12" gives 12.

yday: gives the day in the year, and depends on leap year. For example yday("1984-3-1") gives 61, while yday("1986-3-1") gives 60 wday: gives the day of the week from a date, or date-time variable. For example wday("1984--5-12", label=TRUE) gives Sat d_in_m gives the number of days in the month from date, or date-time. For example d_in_m("1984_2-12") gives 29 as 1984 is a leap year. am: TRUE or FALSE from date-time variable. For example am("1984-05-12 14:23:45") is FALSE

pm: TRUE or FALSE from date-time variable. For example pm("1984-05-12 14:23:45") is TRUE hour Extract hour from date-time variable. For example hour("1984-05-12 14:23:45") is 14. Also hour("1984-05-12") is 0 min Extract minute from date-time variable. For example minute("1984-05-12 14:23:45") is 23 sec Extract second from date-time variable. For example second("1984-05-12 14:23:45") is 45