@@ -3,7 +3,10 @@ package time
33import "time"
44
55// DeisDatetimeFormat is the standard date/time representation used in Deis.
6- const DeisDatetimeFormat string = "2006-01-02T15:04:05MST"
6+ const DeisDatetimeFormat string = "2006-01-02T15:04:05MST"
7+ // Different format to deal with the pyopenssl formatting
8+ // http://www.pyopenssl.org/en/stable/api/crypto.html#OpenSSL.crypto.X509.get_notAfter
9+ const PyOpenSSLTimeDateTimeFormat string = "2006-01-02T15:04:05"
710
811// Time represents the standard datetime format used across the Deis Platform.
912type Time struct {
@@ -24,6 +27,9 @@ func (t *Time) MarshalJSON() ([]byte, error) {
2427// The time is expected to be in Deis' datetime format.
2528func (t * Time ) UnmarshalText (data []byte ) (err error ) {
2629 tt , err := time .Parse (DeisDatetimeFormat , string (data ))
30+ if err != nil {
31+ tt , err = time .Parse (PyOpenSSLTimeDateTimeFormat , string (data ))
32+ }
2733 * t = Time {tt }
2834 return
2935}
@@ -33,6 +39,9 @@ func (t *Time) UnmarshalText(data []byte) (err error) {
3339func (t * Time ) UnmarshalJSON (data []byte ) (err error ) {
3440 // Fractional seconds are handled implicitly by Parse.
3541 tt , err := time .Parse (`"` + DeisDatetimeFormat + `"` , string (data ))
42+ if err != nil {
43+ tt , err = time .Parse (`"` + PyOpenSSLTimeDateTimeFormat + `"` , string (data ))
44+ }
3645 * t = Time {tt }
3746 return
3847}
0 commit comments