This has been defined quite a few times now.  Might be time to move it to a utility file somewhere.