Textual Alarm Input

Using the Text Alarm toolbar icon or dock menu item or the Set Alarm From Text menu item one may set an alarm from text. The syntax for time is very simple and flexible. Here are some examples.

Input TextEquivalent Time
3:14:163 hours, 14 minutes, and 16 seconds.
3 14 163 hours, 14 minutes, and 16 seconds.
5m5 minutes.
5 m5 minutes.
5 minutes5 minutes.
5 martians!!5 minutes.
0:0:0:0:0:5m5 minutes.
2h 57s2 hours and 57 seconds.
2h 572 hours and 57 seconds.
120:572 hours and 57 seconds.
72572 hours and 57 seconds.
59m 1h 117s2 hours and 57 seconds.
1h 57s 1h2 hours and 57 seconds.
6h6 hours.
6 ahoras6 hours.

That probably suffices to give you an idea of what Fob can handle. For those that would benefit from knowing Fob's exact formal scheme:

  1. Define an accumulated number of seconds A=0.
  2. Define an expression number of seconds E=0.
  3. Skip the input string until the next digit character (0-9) or time unit character (H,h,M,m,S,s) -- all other characters (other alphabetic characters, spaces, and : for example) are skipped. If we run into the end of the string, go to step 6.
  4. Attempt to read a number from the string.
    1. If a number can be read, define it as N and set E=60*E + N.
    2. If the reading of a number fails, then the next character must be a time unit character. If the character is H or h, set E=3600*E. If the character is M or m, set E=60*E. Set A=A+E, and then set E=0.
  5. Go to step 3.
  6. Set A=A+E.
  7. Start an alarm for A seconds.

Here's an explanation for some of these examples. The 5 martians!! example is 5 minutes because after reading a five the next relevant character read was m, and there are no other numbers to further modify the time. The 6 ahoras example is 6 hours not because Fob knows Spanish but because after reading six the next relevant character is h, so it skips right over the a. The 59m 1h 117s example is 2:00:57 because it reads 59 minutes plus 1 hour plus 117 seconds which winds up as 2:00:57. Similarity, 1h 57s 1h is 1 hour plus 57 seconds plus 1 hour.