7070use OCP \Files \Node ;
7171use OCP \Files \NotFoundException ;
7272use OCP \IConfig ;
73+ use OCP \IDateTimeZone ;
7374use OCP \IGroupManager ;
7475use OCP \IL10N ;
7576use OCP \IPreview ;
@@ -124,20 +125,6 @@ class ShareAPIController extends OCSController {
124125
125126 /**
126127 * Share20OCS constructor.
127- *
128- * @param string $appName
129- * @param IRequest $request
130- * @param IManager $shareManager
131- * @param IGroupManager $groupManager
132- * @param IUserManager $userManager
133- * @param IRootFolder $rootFolder
134- * @param IURLGenerator $urlGenerator
135- * @param string $userId
136- * @param IL10N $l10n
137- * @param IConfig $config
138- * @param IAppManager $appManager
139- * @param IServerContainer $serverContainer
140- * @param IUserStatusManager $userStatusManager
141128 */
142129 public function __construct (
143130 string $ appName ,
@@ -153,7 +140,8 @@ public function __construct(
153140 IAppManager $ appManager ,
154141 IServerContainer $ serverContainer ,
155142 IUserStatusManager $ userStatusManager ,
156- IPreview $ previewManager
143+ IPreview $ previewManager ,
144+ private IDateTimeZone $ dateTimeZone ,
157145 ) {
158146 parent ::__construct ($ appName , $ request );
159147
@@ -597,7 +585,7 @@ public function deleteShare(string $id): DataResponse {
597585 * @param string $publicUpload If public uploading is allowed
598586 * @param string $password Password for the share
599587 * @param string|null $sendPasswordByTalk Send the password for the share over Talk
600- * @param string $expireDate Expiry date of the share
588+ * @param string $expireDate Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used.
601589 * @param string $note Note for the share
602590 * @param string $label Label for the share (only used in link and email)
603591 * @param string|null $attributes Additional attributes for the share
@@ -1706,11 +1694,12 @@ protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
17061694 */
17071695 private function parseDate (string $ expireDate ): \DateTime {
17081696 try {
1709- $ date = new \DateTime (trim ($ expireDate , "\"" ));
1697+ $ date = new \DateTime (trim ($ expireDate , "\"" ), $ this -> dateTimeZone -> getTimeZone () );
17101698 } catch (\Exception $ e ) {
17111699 throw new \Exception ('Invalid date. Format must be YYYY-MM-DD ' );
17121700 }
17131701
1702+ $ date ->setTimezone (new \DateTimeZone (date_default_timezone_get ()));
17141703 $ date ->setTime (0 , 0 , 0 );
17151704
17161705 return $ date ;
0 commit comments