From 0dfac9875ef6f5f20318a3ef542b11592da8480e Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Mon, 30 May 2016 09:59:53 -0400
Subject: Add license expiry messages (#3153)

---
 webapp/utils/license_utils.jsx | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 webapp/utils/license_utils.jsx

(limited to 'webapp/utils/license_utils.jsx')

diff --git a/webapp/utils/license_utils.jsx b/webapp/utils/license_utils.jsx
new file mode 100644
index 000000000..0ee8b75de
--- /dev/null
+++ b/webapp/utils/license_utils.jsx
@@ -0,0 +1,45 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Constants from 'utils/constants.jsx';
+
+import React from 'react';
+import {FormattedDate} from 'react-intl';
+
+export function isLicenseExpiring() {
+    if (window.mm_license.IsLicensed !== 'true') {
+        return false;
+    }
+
+    const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
+    return timeDiff <= Constants.LICENSE_EXPIRY_NOTIFICATION;
+}
+
+export function isLicenseExpired() {
+    if (window.mm_license.IsLicensed !== 'true') {
+        return false;
+    }
+
+    const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
+    return timeDiff < 0;
+}
+
+export function isLicensePastGracePeriod() {
+    if (window.mm_license.IsLicensed !== 'true') {
+        return false;
+    }
+
+    const timeDiff = Date.now() - parseInt(global.window.mm_license.ExpiresAt, 10);
+    return timeDiff > Constants.LICENSE_GRACE_PERIOD;
+}
+
+export function displayExpiryDate() {
+    return (
+        <FormattedDate
+            value={new Date(parseInt(global.window.mm_license.ExpiresAt, 10))}
+            day='2-digit'
+            month='long'
+            year='numeric'
+        />
+    );
+}
-- 
cgit v1.2.3-1-g7c22

