From fa3d1553a36192209b01ccb68eba3bb323cccf28 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Sat, 3 Oct 2020 14:36:10 -0700 Subject: [PATCH] New birthdate format: YYYMMDD Also, fixed get_date(), it returns 0 on success, but the success return logic was inverted: it only returned 0 if the date was unchanged from the previous value. Note: It would be nice if this user editor prompted to save changes if changes have been made a new user is selected (e.g. with the arrow buttons). --- src/sbbs3/gtkuseredit/events.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sbbs3/gtkuseredit/events.c b/src/sbbs3/gtkuseredit/events.c index db5c6fa8ce..2e33d5ae95 100644 --- a/src/sbbs3/gtkuseredit/events.c +++ b/src/sbbs3/gtkuseredit/events.c @@ -2050,7 +2050,7 @@ int get_date(GtkWidget *t, isoDate_t *date) gtk_calendar_get_date(GTK_CALENDAR(w), &year, &month, &day); gtk_widget_hide(GTK_WIDGET(gtk_widget_get_toplevel(GTK_WIDGET(w)))); *date=isoDate_create(year, month+1, day); - return(odate!=*date); + return odate == *date; } G_MODULE_EXPORT void get_expiration(GtkWidget *t, gpointer data) @@ -2094,18 +2094,19 @@ G_MODULE_EXPORT void get_birthdate(GtkWidget *t, gpointer data) GtkWidget *w; int year; - year=atoi(user.birth+6)+1900; - if(year<Y2K_2DIGIT_WINDOW) - year+=100; - if(cfg.sys_misc&SM_EURODATE) - date=isoDate_create(year, atoi(user.birth+3), atoi(user.birth)); - else - date=isoDate_create(year, atoi(user.birth), atoi(user.birth+3)); - if(!get_date(t, &date)) { + + if(user.birth[2] == '/') { + year=atoi(user.birth+6)+1900; + if(year<Y2K_2DIGIT_WINDOW) + year+=100; if(cfg.sys_misc&SM_EURODATE) - sprintf(user.birth,"%02u/%02u/%02u",isoDate_day(date),isoDate_month(date),isoDate_year(date)%100); + date=isoDate_create(year, atoi(user.birth+3), atoi(user.birth)); else - sprintf(user.birth,"%02u/%02u/%02u",isoDate_month(date),isoDate_day(date),isoDate_year(date)%100); + date=isoDate_create(year, atoi(user.birth), atoi(user.birth+3)); + } else + date = atoi(user.birth); + if(!get_date(t, &date)) { + SAFEPRINTF3(user.birth,"%04u%02u%02u",isoDate_year(date),isoDate_month(date),isoDate_day(date)); user_changed(t, data); w=GTK_WIDGET(gtk_builder_get_object(builder, "eBirthdate")); if(w==NULL) -- GitLab