Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Component/Datetime/Time.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Component\Datetime; | |
4 | |
5 use Symfony\Component\HttpFoundation\RequestStack; | |
6 | |
7 /** | |
8 * Provides a class for obtaining system time. | |
9 */ | |
10 class Time implements TimeInterface { | |
11 | |
12 /** | |
13 * The request stack. | |
14 * | |
15 * @var \Symfony\Component\HttpFoundation\RequestStack | |
16 */ | |
17 protected $requestStack; | |
18 | |
19 /** | |
20 * Constructs a Time object. | |
21 * | |
22 * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack | |
23 * The request stack. | |
24 */ | |
25 public function __construct(RequestStack $request_stack) { | |
26 $this->requestStack = $request_stack; | |
27 } | |
28 | |
29 /** | |
30 * {@inheritdoc} | |
31 */ | |
32 public function getRequestTime() { | |
33 return $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME'); | |
34 } | |
35 | |
36 /** | |
37 * {@inheritdoc} | |
38 */ | |
39 public function getRequestMicroTime() { | |
40 return $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME_FLOAT'); | |
41 } | |
42 | |
43 /** | |
44 * {@inheritdoc} | |
45 */ | |
46 public function getCurrentTime() { | |
47 return time(); | |
48 } | |
49 | |
50 /** | |
51 * {@inheritdoc} | |
52 */ | |
53 public function getCurrentMicroTime() { | |
54 return microtime(TRUE); | |
55 } | |
56 | |
57 } |