1 | sclass AI_DatesBot > AttractorBot { |
2 | Long now; |
3 | |
4 | public void run { |
5 | say("I can resolve dates for you"); |
6 | } |
7 | |
8 | // CONFIG |
9 | |
10 | class Attractor1 > Attractor { |
11 | int month, day; |
12 | |
13 | public bool matches(S s) { |
14 | new Matches m; |
15 | if (find3("* of *", s, m)) { |
16 | month = indexOfIC(englishMonthNames(), $2)+1; |
17 | if (month >= 1) { |
18 | day = or0(ai_indexToNr($1)); |
19 | if (day > 0) true; |
20 | } |
21 | } |
22 | |
23 | if (find3("* * of *", s, m)) { |
24 | if (!eqicOneOf($2, "th", "rd", "nd", "st")) false; |
25 | month = indexOfIC(englishMonthNames(), $3)+1; |
26 | if (month >= 1) { |
27 | day = parseIntOpt($1); |
28 | if (day > 0) true; |
29 | } |
30 | } |
31 | |
32 | false; |
33 | } |
34 | |
35 | public void run { |
36 | say(localYear(nowOr(now)) + "/" + formatInt(month, 2) + "/" + formatInt(day, 2)); |
37 | } |
38 | } |
39 | |
40 | *() { |
41 | standardAttractors(new Attractor1); |
42 | } |
43 | } |
Began life as a copy of #1022819
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022834 |
Snippet name: | AI_DatesBot |
Eternal ID of this version: | #1022834/12 |
Text MD5: | 832f92222d3faafffd37bc9c8612caf5 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-09 23:51:30 |
Source code size: | 956 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 386 / 827 |
Version history: | 11 change(s) |
Referenced in: | [show references] |