summaryrefslogtreecommitdiffstats
path: root/src/utils.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-08-22 20:59:28 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-08-22 20:59:28 +0200
commit2b99cb3f3d43c48d9292707725b6618b18944d42 (patch)
treeb53473af2bb46b121669fee9ba006de04520bc12 /src/utils.cpp
parent289f61e5023758f1ca805d19be5f2c19757090e3 (diff)
downloaddabmux-2b99cb3f3d43c48d9292707725b6618b18944d42.tar.gz
dabmux-2b99cb3f3d43c48d9292707725b6618b18944d42.tar.bz2
dabmux-2b99cb3f3d43c48d9292707725b6618b18944d42.zip
Remove dabUtils.{h,cpp}, move to utils
Also remove the obsolete dump code
Diffstat (limited to 'src/utils.cpp')
-rw-r--r--src/utils.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils.cpp b/src/utils.cpp
index 7221453..7a20c43 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -54,6 +54,21 @@ void get_dab_time(time_t *time, uint32_t *millis)
}
+uint32_t gregorian2mjd(int year, int month, int day)
+{
+ //This is the algorithm for the JD, just substract 2400000.5 for MJD
+ year += 8000;
+ if(month < 3) {
+ year--;
+ month += 12;
+ }
+ uint32_t JD =
+ (year * 365) + (year / 4) - (year / 100) + (year / 400) - 1200820
+ + ((month * 153 + 3) / 5) - 92 + (day - 1);
+
+ return (uint32_t)(JD - 2400000.5); //truncation, loss of data OK!
+}
+
/* We use fprintf here because this doesn't have
* to go to the log.
* But all information below must go into the log.