summaryrefslogtreecommitdiff
path: root/date-fns/src/secondsToMinutes/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'date-fns/src/secondsToMinutes/index.ts')
-rw-r--r--date-fns/src/secondsToMinutes/index.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/date-fns/src/secondsToMinutes/index.ts b/date-fns/src/secondsToMinutes/index.ts
new file mode 100644
index 0000000..530c21e
--- /dev/null
+++ b/date-fns/src/secondsToMinutes/index.ts
@@ -0,0 +1,31 @@
+import requiredArgs from '../_lib/requiredArgs/index'
+import { secondsInMinute } from '../constants/index'
+
+/**
+ * @name secondsToMinutes
+ * @category Conversion Helpers
+ * @summary Convert seconds to minutes.
+ *
+ * @description
+ * Convert a number of seconds to a full number of minutes.
+ *
+ * @param {number} seconds - number of seconds to be converted
+ *
+ * @returns {number} the number of seconds converted in minutes
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // Convert 120 seconds into minutes
+ * const result = secondsToMinutes(120)
+ * //=> 2
+ *
+ * @example
+ * // It uses floor rounding:
+ * const result = secondsToMinutes(119)
+ * //=> 1
+ */
+export default function secondsToMinutes(seconds: number): number {
+ requiredArgs(1, arguments)
+ const minutes = seconds / secondsInMinute
+ return Math.floor(minutes)
+}