<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _extract_when(body):
 """Extract the generated datetime from the notification."""


        # NOTE: I am keeping the logic the same as it was in openstack
        # code, However, *ALL* notifications should have a 'timestamp'
        # field, it's part of the notification envelope spec. If this was
        # put here because some openstack project is generating notifications
        # without a timestamp, then that needs to be filed as a bug with the
        # offending project (mdragon)
        when = body.get('timestamp', body.get('_context_timestamp'))
        if when:
            return Datatype.datetime.convert(when)
        return utcnow()