1 # This file is part of Email-Reminder.
3 # Email-Reminder is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation; either version 3 of the
6 # License, or (at your option) any later version.
8 # Email-Reminder is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Email-Reminder; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 package EmailReminder
::Utils
;
20 # Utility subroutines for the Email-Reminder program
25 our $VERSION = '0.7.5';
26 our $USER_CONFIG_FILE = '.email-reminders';
27 our $SPOOL_DIRECTORY = '/var/spool/email-reminder';
61 $node = $node->getElementsByTagName($tag_name, 0)->item(0);
64 $node = $node->getFirstChild;
67 return $node->getNodeValue;
72 my ($node, $tag_name, $new_value) = @_;
74 my $subnode = $node->getElementsByTagName($tag_name, 0)->item(0);
75 if (!defined($subnode))
77 $subnode = $node->getOwnerDocument()->createElement($tag_name);
78 $node->appendChild($subnode);
79 $subnode->addText($new_value);
83 my $textnode = $subnode->getFirstChild();
84 if (!defined($textnode))
86 $subnode->addText($new_value);
90 $textnode->setNodeValue($new_value);
96 # Returns the proper English qualifier for this number
100 return unless defined($number);
102 if ($number >= 11 && $number <= 13) {
104 } elsif ($number % 10 == 1) {
106 } elsif ($number % 10 == 2) {
108 } elsif ($number % 10 == 3) {
115 # Returns the traditional name for this occurence of the anniversary
116 # if applicable (e.g. Silver, Golden, Diamond)
117 # (see http://www.the-inspirations-store.com/acatalog/anniversary.html)
120 my $occurence = shift;
122 return unless exists $names{$occurence};
123 return "($names{$occurence}) ";