From 441f8f731bc6c846d94e5c5bf63f32a285653190 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 6 Jun 2018 23:07:20 +0000
Subject: [PATCH]  Library to return a list of users with a specified birthday
 or birthmonth

---
 exec/load/birthdays.js | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 exec/load/birthdays.js

diff --git a/exec/load/birthdays.js b/exec/load/birthdays.js
new file mode 100644
index 0000000000..61daef6000
--- /dev/null
+++ b/exec/load/birthdays.js
@@ -0,0 +1,38 @@
+// $Id$
+
+// Find users with the specified birthday (or birthmonth)
+
+// Usage (Birthdays in January):
+// list = load({}, "birthdays.js", 0);
+
+// Usage (Birthdays this month):
+// list = load({}, "birthdays.js", new Date().getMonth());
+
+// Usage (Birthdays today):
+// 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
+function birthdays(month, day)
+{
+	var u = new User(1);
+	var lastuser = system.stats.total_users;
+	var list = [];
+	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)
+			continue;
+		if(day && u.birthDate.getDate() != day)
+			continue;
+		list.push(u.number);
+	}
+	return list;
+}
+
+birthdays(argv[0], argv[1]);
-- 
GitLab