diff options
author | Aaron Parecki <aaron@parecki.com> | 2023-10-08 21:05:18 +0000 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2023-10-08 21:05:18 +0000 |
commit | 01f99ab9407ad1e4235b90344181ae4ba96bd9dc (patch) | |
tree | 9d7fd2af40cbbfc0f46c3d4279c05fb64199f169 /controllers | |
parent | 17c5d57fd05cb4ee5b0b189bd4cbf519fb636d41 (diff) |
add published date to weight page
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/controllers.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php index 7b7234c..b1d96c4 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -1039,7 +1039,7 @@ $app->get('/map-img', function() use($app) { }); -function create_weight(&$user, $weight_num, $weight_unit) { +function create_weight(&$user, $weight_num, $weight_unit, $published) { $micropub_request = array( 'type' => ['h-entry'], 'properties' => [ @@ -1052,6 +1052,11 @@ function create_weight(&$user, $weight_num, $weight_unit) { ]] ] ); + try { + $date = new DateTime($published); + $micropub_request['properties']['published'] = [$date->format('c')]; + } catch(Exception $e) { + } $r = micropub_post_for_user($user, $micropub_request, null, true); return $r; @@ -1070,7 +1075,7 @@ $app->post('/weight', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); - $r = create_weight($user, $params['weight_num'], $user->weight_unit); + $r = create_weight($user, $params['weight_num'], $user->weight_unit, $params['published']); $location = $r['location']; $app->response()['Content-type'] = 'application/json'; |