In-Game Event Calendar

Coded in PennMUSH. Store system in Master Room (#2).

Part 1 - The Global
@create JTS Calendar v1.00

@link JTS Calendar v1.00 = #0

@set JTS Calendar v1.00 = ROYALTY

@set JTS Calendar v1.00 = SAFE

&CMD_CALENDAR JTS Calendar v1.00=$+calendar:think [iter([sort(lattr(v(V_DB)),n)],if(gt(secs,[add(86400,[val(##)])]),wipe(v(V_DB)/##)))];@pemit %#=[ansi(y,-)][ansi(y,center(,76))][ansi(y,-)]%R[ansi(y,-)][ansi(y,center(Sponsored by: [v(V_SPONSOR)],76))][ansi(y,-)]%R[setq(0,0)][iter(sort(lattr(v(V_DB)),n),%R[if([neq(u(fn_midnight_secs,%q0),u(fn_midnight_secs,##))],[setq(1,convsecs(##))]%B[grab(v(LIST_DAYS_LONG),[first(%q1)]*)]\, [grab(v(LIST_MONTHS_LONG),[elements(%q1,2)]*)] [elements(%q1,3)] [last(%q1)]%R)]%B%B[setq(0,u(fn_midnight_secs,##))][ansi(y,u(fn_nice_time,elements(elements(convsecs(##),4),1 2,:)))] [rest(get(v(V_DB)/##))] [if(isadmin(%#), - [name(first(get(v(V_DB)/##)))])])][if(u(fn_canpost,%#),%R[ansi(y,-)][center([ansi(y,+calendar/post MM/DD/YYYY-HH:MM= )],76)][ansi(y,-)]%R[ansi(y,-)][center([ansi(y,+calendar/remove MM/DD/YYYY-HH:MM)],76)][ansi(y,-)],%R[ansi(y,-)][space(76)][ansi(y,-)])]

&CMD_POST JTS Calendar v1.00=$+calendar/post *=*:@switch [setq(0,u(fn_input2secs,%0))][u(fn_canpost,%#)][t(gte(%q0,0))][not(hasattr(v(V_DB),%q0))] = 0*,{@pemit %#=[ansi(y,You do not have access to add an entry to the calendar.)]},10*,{@pemit %#=[ansi(y,Invalid time format specified!)]},110*,{@pemit %#=[ansi(y,A post already exists with that date and time.)]},111,{@pemit %#=[ansi(y,You have added an entry to the calendar at [convsecs(%q0)])];&%q0 [v(V_DB)]=%# %1;@dolist lwho = {@pemit ##=[ansi(y,A new calendar entry has been added for [convsecs(%q0)].)]}

&CMD_REMOVE JTS Calendar v1.00=$+calendar/remove *:@switch [setq(0,u(fn_input2secs,%0))][or(match(first(get(v(V_DB)/%q0)),%#),u(fn_candel,%#))][hasattr(v(V_DB),%q0)] = 0*,{@pemit %#=[ansi(y,You can't remove someone else's entry -- it's not very polite.)]},10*,{@pemit %#=[ansi(y,There is no entry for that date and time to delete!)]},11,{@pemit %#=[ansi(y,Entry removed.)];@wipe [v(V_DB)]/%q0}

@DESCRIBE JTS Calendar v1.00=The +calendar commands.

@set JTS Calendar v1.00/DESCRIBE=no_command visual

&FN_2DIGIT JTS Calendar v1.00=[if(eq(strlen(%0),1),0%0,right(%0,2))]

@set JTS Calendar v1.00/FN_2DIGIT=no_command

&FN_CANDEL JTS Calendar v1.00=orflags(%0,Wr)

@set JTS Calendar v1.00/FN_CANDEL=no_command

&FN_CANPOST JTS Calendar v1.00=[or([not([hasflag(%0,UNREGISTERED)])],[orflags(%0,Wr)])]

@set JTS Calendar v1.00/FN_CANPOST=no_command

&FN_DAY JTS Calendar v1.00=switch(%0,Sun,Sunday,Mon,Monday,Tue,Tuesday,Wed,Wednesday,Thu,Thursday,Fri,Friday,Sat,Saturday)

@set JTS Calendar v1.00/FN_DAY=no_command

&FN_INPUT2SECS JTS Calendar v1.00=[convtime(??? [elements(v(LIST_MONTHS),first(%0,/))] [u(fn_2digit,elements(%0,2,/))] [u(fn_2digit,first(last(%0,-),:))]:[u(fn_2digit,rest(last(%0,-),:))]:00 [first(last(%0,/),-)])]

@set JTS Calendar v1.00/FN_INPUT2SECS=no_command

&FN_MIDNIGHT_SECS JTS Calendar v1.00=[convtime([elements(convsecs(%0),1 2 3)] 00:00:00 [last(convsecs(%0))])]

@set JTS Calendar v1.00/FN_MIDNIGHT_SECS=no_command

&FN_NICE_TIME JTS Calendar v1.00=[if(gt(first(%0,:),12),sub(val(first(%0,:)),12):[rest(%0,:)]PM,[if(eq([val(first(%0,:))],0),12,[val(first(%0,:))])]:[rest(%0,:)][if(eq(val(first(%0,:)),0),AM,PM)]

@set JTS Calendar v1.00/FN_NICE_TIME=no_command

&LIST_DAYS_LONG JTS Calendar v1.00=Sunday Monday Tuesday Wednesday Thursday Friday Saturday

@set JTS Calendar v1.00/LIST_DAYS_LONG=no_command

&LIST_MONTHS JTS Calendar v1.00=Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

@set JTS Calendar v1.00/LIST_MONTHS=no_command

&LIST_MONTHS_LONG JTS Calendar v1.00=January February March April May June July August September October November December

@set JTS Calendar v1.00/LIST_MONTHS_LONG=no_command

&V_DB JTS Calendar v1.00=

@set JTS Calendar v1.00/V_DB=no_command

&V_SPONSOR JTS Calendar v1.00=

Part 2 - The Database Object
@create JTS Calendar Storage Object

@tel JTS Calendar Storage Object to the Calendar Global object