Adding or subtracting a month to a Python or datetime.datetime is a little bit of a pain. These functions return the same datetime type as given.They preserve time of day data (if that is at all...This script contains an e-mail address validation function.It allows the usual [email protected] syntax, but in addition allows [email protected][ip] format as well as "User with Spaces"@domain or [ip], all of which are legal syntax, according to W3C. One of the most popular form validation tasks is to check that important fields within a form have been filled out by the user.It seems like something that should exist already, so I'd just like to check before I attempt my own version...Cheers, Mark It should be reasonably straight forward to add a validates_date_time method to my plugin. Is there a particular reason that validates_date and validates_time doesn't use the above method for Date and Time? Date.parse(value_before_type_cast.to_s) Rescue I've messed around with the plugin and got it doing something approaching what I need, but it's not very tidy yet.import re from ifware.calendar import days_in_month def get_integers(alist): result =  for x in alist: try: result.append(int(x)) except Value Error: result.append(0) return result # A regular expression that matches timestamps. ' # Tenths of milliseconds (may follow seconds when present) r')? ' # Timezone (optional) r'$' ) def parse_time(timestamp): matches = ts_regex.findall(timestamp) if len(matches) parse_time() expects one parameter, which is the timestamp that needs to be validated.ts_regex = re.compile( r'^' r'(\d)' # Year (4 digits) r'(\d)' # Month r'(\d)' # Day r'(\d)' # Hour r'(\d)' # Minute r'(? If it detects an invalid timestamp component, it raises a Value Error exception; otherwise, it returns the components of the timestamp.
The Date Time Suite is an extensive range of Components and Classes that fully encapsulate Date and Time editing.
UUsing Regular Expressions, it is simple to search for a specific word or string of characters.
Almost every editor on every computer system can do this.
Cheers, Mark This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. I don't mind spending a bit of time adding this sort of functionality to the plugin, I'm sure others will find it useful and I will probably need it in a month or so anyway.
Email communications with the University of Nottingham may be monitored as permitted by UK legislation.