aboutsummaryrefslogtreecommitdiff
path: root/common/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/helper.c')
-rw-r--r--common/helper.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/common/helper.c b/common/helper.c
index afdb7f3..2826ceb 100644
--- a/common/helper.c
+++ b/common/helper.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */
-/* Updated: 2020/02/14 01:37:31 by cacharle ### ########.fr */
+/* Updated: 2020/02/14 21:07:54 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -74,7 +74,15 @@ t_time h_timeval_to_time(struct timeval *tp)
{
t_time t;
- t = tp->tv_sec * 1000;
- t += tp->tv_usec / 1000;
+ t = tp->tv_sec * 1000 + tp->tv_usec / 1000;
return (t);
}
+
+t_time h_time_now(void)
+{
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) == -1)
+ return (-1);
+ return (h_timeval_to_time(&tv));
+}