JURASSIC
jsec2time.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
32static void usage(
33 void);
34
35/* ------------------------------------------------------------
36 Main...
37 ------------------------------------------------------------ */
38
39int main(
40 int argc,
41 char *argv[]) {
42
43 double remain;
44
45 int day, hour, min, mon, sec, year;
46
47 /* Print usage information... */
48 USAGE;
49
50 /* Check arguments... */
51 if (argc < 2)
52 ERRMSG("Missing or invalid command-line arguments.\n\n"
53 "Usage: jsec2time <jsec>\n\n" "Use -h for full help.");
54
55 /* Read arguments... */
56 const double jsec = atof(argv[1]);
57
58 /* Convert time... */
59 jsec2time(jsec, &year, &mon, &day, &hour, &min, &sec, &remain);
60 printf("%d %d %d %d %d %d %g\n", year, mon, day, hour, min, sec, remain);
61
62 return EXIT_SUCCESS;
63}
64
65/*****************************************************************************/
66
67static void usage(
68 void) {
69 printf("\nJURASSIC time converter.\n\n");
70 printf
71 ("Convert Julian seconds since 2000-01-01T00:00Z to calendar time.\n\n");
72 printf("Usage:\n");
73 printf(" jsec2time <jsec>\n\n");
74 printf("Arguments:\n");
75 printf(" <jsec> Seconds since 2000-01-01T00:00Z.\n\n");
76 printf("Output:\n");
77 printf(" Writes results to standard output as:\n");
78 printf(" year month day hour minute second remainder\n\n");
79 printf("Further information:\n");
80 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
81}
void usage(void)
Print command-line help.
Definition: formod.c:163
int main(int argc, char *argv[])
Definition: jsec2time.c:39
void jsec2time(const double jsec, int *year, int *mon, int *day, int *hour, int *min, int *sec, double *remain)
Converts Julian seconds to calendar date and time components.
Definition: jurassic.c:4354
JURASSIC library declarations.
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: jurassic.h:1325
#define USAGE
Print usage information on -h or --help.
Definition: jurassic.h:1206