MPTRAC
Loading...
Searching...
No Matches
src
time2jsec.c
Go to the documentation of this file.
1
/*
2
This file is part of MPTRAC.
3
4
MPTRAC is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
MPTRAC is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
16
17
Copyright (C) 2013-2026 Forschungszentrum Juelich GmbH
18
*/
19
25
#include "
mptrac.h
"
26
27
/* ------------------------------------------------------------
28
Functions...
29
------------------------------------------------------------ */
30
32
void
usage
(
33
void
);
34
35
/* ------------------------------------------------------------
36
Main...
37
------------------------------------------------------------ */
38
39
int
main
(
40
int
argc,
41
char
*argv[]) {
42
43
double
jsec;
44
45
/* Print usage information... */
46
USAGE
;
47
48
/* Check arguments... */
49
if
(argc < 8)
50
ERRMSG
(
"Missing or invalid command-line arguments.\n\n"
51
"Usage: time2jsec <year> <mon> <day> <hour> <min> <sec> <remain>\n\n"
52
"Use -h for full help."
);
53
54
/* Read arguments... */
55
const
int
year = atoi(argv[1]);
56
const
int
mon = atoi(argv[2]);
57
const
int
day = atoi(argv[3]);
58
const
int
hour = atoi(argv[4]);
59
const
int
min = atoi(argv[5]);
60
const
int
sec = atoi(argv[6]);
61
const
double
remain = atof(argv[7]);
62
63
/* Convert... */
64
time2jsec
(year, mon, day, hour, min, sec, remain, &jsec);
65
printf(
"%.2f\n"
, jsec);
66
67
return
EXIT_SUCCESS;
68
}
69
70
/*****************************************************************************/
71
73
void
usage
(
74
void
) {
75
76
printf(
"\nMPTRAC time2jsec tool.\n\n"
);
77
printf(
"Convert calendar time to seconds since 2000-01-01 00:00 UTC.\n"
);
78
printf(
"\n"
);
79
printf(
"Usage:\n"
);
80
printf(
" time2jsec <year> <mon> <day> <hour> <min> <sec> <remain>\n"
);
81
printf(
"\n"
);
82
printf(
"Arguments:\n"
);
83
printf(
" <year> Year.\n"
);
84
printf(
" <mon> Month.\n"
);
85
printf(
" <day> Day of month.\n"
);
86
printf(
" <hour> Hour.\n"
);
87
printf(
" <min> Minute.\n"
);
88
printf(
" <sec> Second.\n"
);
89
printf(
" <remain> Fractional-second remainder.\n"
);
90
printf(
"\nFurther information:\n"
);
91
printf(
" Manual: https://slcs-jsc.github.io/mptrac/\n"
);
92
}
time2jsec
void time2jsec(const int year, const int mon, const int day, const int hour, const int min, const int sec, const double remain, double *jsec)
Converts time components to seconds since January 1, 2000, 12:00:00 UTC.
Definition
mptrac.c:13505
mptrac.h
MPTRAC library declarations.
ERRMSG
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition
mptrac.h:2426
USAGE
#define USAGE
Print usage information on -h or --help.
Definition
mptrac.h:2233
main
int main(int argc, char *argv[])
Definition
time2jsec.c:39
usage
void usage(void)
Print command-line help.
Definition
time2jsec.c:73
Generated on Tue Nov 10 2026 15:48:54 for MPTRAC by
1.12.0