0

I'm trying to load a datetime field with the following format.

2013-02-05T10:09:38-08:00

- property: event_time
  external_name: datetime
  import_transform: transform.import_date_time('%Y-%m-%dT%H:%M:%S%z')

However, the transformer does not accept the %z directive. According to the Python docs, this directive is platform dependent. Apparently, App Engine doesn't support it. Here's the error I get on the bulkloader,

ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M:%S%z'

This issue seems to be well established in the context of datetime parsing and there are workarounds. But what to do with the bulkloader? I don't have the same flexibility as other Python solutions.

Greg
  • 2,559
  • 4
  • 28
  • 46

1 Answers1

0

I store only naïve datetime objects, so I haven't run into this problem myself. But it would seem to be possible to write a custom export/import pair, that includes something to recreate the timezone offset.... e.g. the export might be something like:

def export_datetime_with_gmt_offset(dt):
   return transform.export_date_time('%Y-%m-%dT%H:%M:%S')(dt) + ' ' + dt.utcoffset().minutes

(Code above not tested, but with luck it'll set you on the right path.)

Jeremy
  • 1,049
  • 1
  • 15
  • 28