[eluser]OverZealous[/eluser]
I'm not going to bother linking. Please read the manual, and look at validation (for converting before saving) and get_rules (for converting after queries).
Your first two examples are explicitly defined within the docs! The third is a trivial variation on the theme, and there are already built-in modifiers for that one.