...
 
Commits (2)
require('sbbsdefs.js', 'LEN_ALIAS');
var month = argv[0];
var day = argv[1];
if(month === undefined)
month = new Date().getMonth();
var list = load({}, "birthdays.js", month, day);
var monthNameList = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
if(js.global.console) console.attributes = HIGH;
print(format("%u %s users with birthdays in %s:", list.length, system.name, monthNameList[month]));
for(var i = 0; i < list.length; i++) {
if(js.global.console) console.attributes = HIGH | ((i&1) ? CYAN : MAGENTA);
var u = User(list[i]);
var str = format("%-*s ", LEN_ALIAS, u.alias);
if((js.global.console && console.current_column + str.length > console.screen_columns) || (!js.global.console && i > 0 && i % 3 == 0))
print();
write(str);
}
print();
// $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);
});
// $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);
}
......