Skip to content

Commit

Permalink
Use RFC1123 format for Memento-Datetime response header
Browse files Browse the repository at this point in the history
  • Loading branch information
jlicht committed Mar 4, 2015
1 parent 660660d commit 2a3cc06
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion amber/amber.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,15 @@ public static function custom_query_vars($vars) {
return $vars;
}

/**
* Convert a string representation of a date into RFC1123 format
*/
public static function format_memento_date($date_string) {
$storage = Amber::get_storage();
$dt = DateTime::createFromFormat($storage->ISO8601_FORMAT, $date_string);
$result = $dt->format(DateTime::RFC1123);
return $result;
}

/**
* Request handling function to display cached content and assets
Expand Down Expand Up @@ -551,7 +560,8 @@ public static function filter_cached_content_headers($headers)
$data = Amber::retrieve_cache_item($cache_id, false);
}
if (isset($data['metadata']['cache']['amber']['date'])) {
$headers['Memento-Datetime'] = $data['metadata']['cache']['amber']['date'];
$memento_date = Amber::format_memento_date($data['metadata']['cache']['amber']['date']);
$headers['Memento-Datetime'] = $memento_date;
}
}
return $headers;
Expand Down

0 comments on commit 2a3cc06

Please sign in to comment.