summaryrefslogtreecommitdiff
path: root/pjlib/src/pj/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'pjlib/src/pj/types.c')
-rw-r--r--pjlib/src/pj/types.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/pjlib/src/pj/types.c b/pjlib/src/pj/types.c
new file mode 100644
index 00000000..ee1a8588
--- /dev/null
+++ b/pjlib/src/pj/types.c
@@ -0,0 +1,36 @@
+/* $Header: /pjproject-0.3/pjlib/src/pj/types.c 4 9/17/05 10:37a Bennylp $ */
+/* $Log: /pjproject-0.3/pjlib/src/pj/types.c $
+ *
+ * 4 9/17/05 10:37a Bennylp
+ * Major reorganization towards version 0.3.
+ *
+ */
+#include <pj/types.h>
+#include <pj/os.h>
+
+void pj_time_val_normalize(pj_time_val *t)
+{
+ PJ_CHECK_STACK();
+
+ if (t->msec >= 1000) {
+ do {
+ t->sec++;
+ t->msec -= 1000;
+ } while (t->msec >= 1000);
+ }
+ else if (t->msec <= -1000) {
+ do {
+ t->sec--;
+ t->msec += 1000;
+ } while (t->msec <= -1000);
+ }
+
+ if (t->sec >= 1 && t->msec < 0) {
+ t->sec--;
+ t->msec += 1000;
+
+ } else if (t->sec < 0 && t->msec > 0) {
+ t->sec++;
+ t->msec -= 1000;
+ }
+}