#!/bin/sh

set -eu

if ! grep -qEe '^ -- ' debian/changelog; then
    echo 'Unable to find date in debian/changelog' 1>&2
    exit 2
fi

date="$(grep -E -e ' -- ' debian/changelog | head -1)"
test "$date"
date="$(echo "$date" | sed -Ee 's/.* (\S+ \S+ \S+ \S+ \S+)$/\1/')"
date="$(./rewrite-time "$date" '%d %b %Y %H:%M:%S %z' '%Y-%m-%d')"
echo "$date"
