Open whesse opened 5 years ago
I suppose the comment in issue #26, that users can easily write their own parser for the user-readable format, is true. This issue can be closed. Example in Dart of converting this format to ISO format:
DateTime parseGitilesDateTime(String gitiles) { final parts = gitiles.split(' '); final year = parts[4]; const month = { 'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12' }[parts[1]]; final day = parts[2].padLeft(2, '0'); return DateTime.parse('$year-$month-$day ${parts[3]} ${parts[5]}'); }
I think it would be reasonable to support a query parameter to request UNIX time.
The date format in JSON output is the same used by git log
by default, it can be parsed with generic time/data tools like strptime
.
An example with jq
to convert that date to the RFC 5322 format used in git format-patch
:
cat out.json | jq '.author.time | strptime("%a %b %d %H:%M:%S %Y") | strftime("%a, %d %b %Y %H:%M:%S") + .[8]'
The date/time format in the JSON output of the +log endpoint is hard to parse without including internationalization libraries. It includes month names in English, and can't be parsed in Dart without writing a custom conversion function that includes conversion of months and parsing.
Issue #26 has some discussion about this, but the explanation doesn't say why the ISO format wasn't used. The only difference is that it doesn't show the day of the week, and it shows the month as a number. And most languages have support for parsing ISO format.