From 6112ebc9bddc4b2ec1faa64bc9b77f8d574162f0 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Thu, 12 Nov 2020 20:52:13 -0800 Subject: [PATCH] Use the newest methods of getting a user's birth month/day. Remove birthdate.js - not needed or used anywhere (anymore). --- exec/load/birthdate.js | 21 --------------------- exec/load/birthdays.js | 8 +++----- 2 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 exec/load/birthdate.js diff --git a/exec/load/birthdate.js b/exec/load/birthdate.js deleted file mode 100644 index 9115e326f0..0000000000 --- a/exec/load/birthdate.js +++ /dev/null @@ -1,21 +0,0 @@ -// $Id: birthdate.js,v 1.4 2018/06/06 21:44:23 rswindell Exp $ -/* - * When this code is load()ed, User objects get an extra 'birthDate' property - * which is a JavaScript Date object representing the user's birthdate. - */ - -User.prototype.__defineGetter__("birthDate", function() { - var mfirst=system.datestr(1728000).substr(0,2)=='01'; - var match; - var m,d,y; - - match=this.birthdate.match(/^([0-9]{2})[-/]([0-9]{2})[-/]([0-9]{2})$/); - if(match==null) - return undefined; - m=parseInt(match[mfirst?1:2],10)-1; - d=parseInt(match[mfirst?2:1],10); - y=parseInt(match[3],10)+1900; - if(this.age + y < (new Date()).getYear()-2) - y+=100; - return new Date(y,m,d); -}); diff --git a/exec/load/birthdays.js b/exec/load/birthdays.js index 6782a15d9a..0d541ed381 100644 --- a/exec/load/birthdays.js +++ b/exec/load/birthdays.js @@ -1,5 +1,3 @@ -// $Id: birthdays.js,v 1.1 2018/06/06 23:07:20 rswindell Exp $ - // Find users with the specified birthday (or birthmonth) // Usage (Birthdays in January): @@ -12,7 +10,6 @@ // list = load({}, "birthdays.js", new Date().getMonth(), new Date().getDate()); load("sbbsdefs.js"); -load("birthdate.js"); // Returns an array of user numbers // Note: month is 0-based, day (of month) is optional and 1-based @@ -21,14 +18,15 @@ function birthdays(month, day) var u = new User; var lastuser = system.stats.total_users; var list = []; + month = parseInt(month, 10) + 1; for(u.number = 1; u.number <= lastuser; u.number++) { if(u.settings&(USER_DELETED|USER_INACTIVE)) continue; if(u.security.restrictions&(UFLAG_Q|UFLAG_G)) continue; - if(u.birthDate.getMonth() != month) + if(u.birthmonth != month) continue; - if(day && u.birthDate.getDate() != day) + if(day && u.birthday != day) continue; list.push(u.number); } -- GitLab