JURASSIC
Loading...
Searching...
No Matches
src
time2jsec.c
Go to the documentation of this file.
1
/*
2
This file is part of JURASSIC.
3
4
JURASSIC 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
JURASSIC 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 JURASSIC. If not, see <http://www.gnu.org/licenses/>.
16
17
Copyright (C) 2003-2026 Forschungszentrum Juelich GmbH
18
*/
19
25
#include "
jurassic.h
"
26
27
/* ------------------------------------------------------------
28
Functions...
29
------------------------------------------------------------ */
30
32
static
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
72
static
void
usage
(
73
void
) {
74
printf(
"\nJURASSIC time converter.\n\n"
);
75
printf
76
(
"Convert calendar time to Julian seconds since 2000-01-01T00:00Z.\n\n"
);
77
printf(
"Usage:\n"
);
78
printf(
" time2jsec <year> <mon> <day> <hour> <min> <sec> <remain>\n\n"
);
79
printf(
"Arguments:\n"
);
80
printf(
" <year> Calendar year.\n"
);
81
printf(
" <mon> Calendar month.\n"
);
82
printf(
" <day> Day of month.\n"
);
83
printf(
" <hour> Hour.\n"
);
84
printf(
" <min> Minute.\n"
);
85
printf(
" <sec> Integer second.\n"
);
86
printf(
" <remain> Fractional remainder of the second.\n\n"
);
87
printf(
"Output:\n"
);
88
printf(
" Writes results to standard output.\n\n"
);
89
printf(
"Further information:\n"
);
90
printf(
" Manual: https://slcs-jsc.github.io/jurassic/\n"
);
91
}
usage
void usage(void)
Print command-line help.
Definition
formod.c:273
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
jurassic.c:8110
jurassic.h
JURASSIC library declarations.
ERRMSG
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition
jurassic.h:1453
USAGE
#define USAGE
Print usage information on -h or --help.
Definition
jurassic.h:1334
main
int main(int argc, char *argv[])
Definition
time2jsec.c:39
Generated on Mon Nov 23 2026 22:05:26 for JURASSIC by
1.12.0