Commit bad69b46 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

more series code to extract SFF data

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
provide new constructor for TRelativeTime


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1451
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 25c0c754
/* this is <base_constr.cc>
* ----------------------------------------------------------------------------
*
* $Id: base_constr.cc,v 1.6 2003-12-22 13:23:40 tforb Exp $
* $Id: base_constr.cc,v 1.7 2004-01-13 19:50:55 tforb Exp $
*
* 09/08/2000 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -54,7 +54,22 @@ TAbsoluteTime now()
int second=nowtm->tm_sec;
TAbsoluteTime thetime(year, month, day, hour, minute, second);
return(thetime);
}
} // now()
TRelativeTime::TRelativeTime(const double& seconds):
TBaseClassTime(0, 0, 0, 0, 0, 0, 0)
{
double remain=seconds;
typedef long int li;
Mtime_Ts.second=li(seconds);
remain-=double(Mtime_Ts.second);
remain*=1.e3;
Mtime_Ts.milsec=li(remain);
remain-=double(Mtime_Ts.milsec);
remain*=1.e3;
Mtime_Ts.micsec=li(remain);
norm();
} // TRelativeTime::TRelativeTime(const double& seconds)
}; // namespace libtime
......
# this is <Makefile>
# ----------------------------------------------------------------------------
# Makefile for work/src/libs/libtime
# ($Id: Makefile,v 2.16 2002-11-14 15:10:06 forbrig Exp $)
# ($Id: Makefile,v 2.17 2004-01-13 19:50:55 tforb Exp $)
#
# 06/08/2000 by Thomas Forbriger (IfG Stuttgart)
#
......@@ -192,6 +192,8 @@ tests: $(patsubst %.c,%,$(CTESTS)) $(patsubst %.f,%,$(FTESTS)) \
$(patsubst %.f,%77,$(FTESTS)) $(patsubst %.cc,%,$(CXXTESTS))
for d in $^; do /bin/echo -e "\n\nGO FOR $$d?"; read a; $$d; done
%.run: tests/%; $<; /bin/rm -fv $<
testsexe:
for d in $(TESTS); do /bin/echo -e "\n\nGO FOR $$d?"; read a; $$d; done
......@@ -258,6 +260,11 @@ wwwdistrib: libtime.tar.gz libtime.doc
wwwclean:
/bin/rm -rfv wwwpath/* wwwpath
doc/html/index.html: doxyfull.cfg $(ALLCODE); doxygen $<
doxydoc: doc/html/index.html
doxyview: doc/html/index.html; mozilla file://$(shell pwd)/$< &
#======================================================================
#
# distribution package
......
/* this is <libtime++.h>
* ----------------------------------------------------------------------------
*
* $Id: libtime++.h,v 2.10 2003-12-30 17:23:05 tforb Exp $
* $Id: libtime++.h,v 2.11 2004-01-13 19:50:55 tforb Exp $
*
* Copyright (c) by Thomas Forbriger (IfG Stuttgart)
*
......@@ -20,13 +20,14 @@
* 22/12/2003 V1.6 whooo - was a bit sloppy - corrected some errors
* 27/12/2003 V1.7 added member function of TAbsoluteTime to
* set doy explicitely
* 13/01/2004 V1.8 added constructor from double for TRelativeTime
*
* ============================================================================
*/
#ifndef TF_LIBTIME_H_
#define TF_LIBTIME_H_ \
"$Id: libtime++.h,v 2.10 2003-12-30 17:23:05 tforb Exp $";
"$Id: libtime++.h,v 2.11 2004-01-13 19:50:55 tforb Exp $";
#include <string>
#include "libtime.h"
......@@ -129,6 +130,7 @@ class TRelativeTime: public TBaseClassTime {
TRelativeTime(const long int &days=0, const long int &hour=0,
const long int &minute=0, const long int &second=0,
const long int &milsec=0, const long int &micsec=0);
explicit TRelativeTime(const double& seconds);
long int days() const;
void nfit(const TRelativeTime &delta, long int &n, TRelativeTime &full)
......
/* this is <testtime++.cc>
* ----------------------------------------------------------------------------
*
* $Id: testtime++.cc,v 1.5 2002-11-14 14:24:01 forbrig Exp $
* $Id: testtime++.cc,v 1.6 2004-01-13 19:50:56 tforb Exp $
*
* 09/08/2000 by Thomas Forbriger (IfG Stuttgart)
*
......@@ -10,6 +10,7 @@
* REVISIONS and CHANGES
* 09/08/2000 V1.0 Thomas Forbriger
* 22/12/2000 V1.1 changed namespace time to libtime
* 13/01/2004 V1.2 test constructor for TRelativeTime from double
*
* ============================================================================
*/
......@@ -62,6 +63,16 @@ void Rinit_from_value(const long int &days,
<< milsec << " " << micsec << endl;
}
void init_from_seconds(const double& seconds)
{
libtime::TRelativeTime value(seconds);
std::cout << value.timestring()
<< " initialized from "
<< seconds
<< " seconds"
<< endl;
}
/*
* main testing code
*/
......@@ -94,6 +105,14 @@ int main()
init_from_string<libtime::TRelativeTime>("8");
init_from_string<libtime::TRelativeTime>("123.23.34.45.56789");
init_from_string<libtime::TRelativeTime>("123.2345.34567.45678.56789");
init_from_seconds(1.e-6);
init_from_seconds(1.e-3);
init_from_seconds(1.);
init_from_seconds(60.);
init_from_seconds(3600.);
init_from_seconds(86400.);
init_from_seconds(123.345763);
init_from_seconds(871323.345763);
std::cout << endl;
Rinit_from_value(0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment