JURASSIC
doy2day.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 int day, mon;
44
45 /* Print usage information... */
46 USAGE;
47
48 /* Check arguments... */
49 if (argc < 3)
50 ERRMSG("Missing or invalid command-line arguments.\n\n"
51 "Usage: doy2day <year> <doy>\n\n" "Use -h for full help.");
52
53 /* Read arguments... */
54 const int year = atoi(argv[1]);
55 const int doy = atoi(argv[2]);
56
57 /* Convert... */
58 doy2day(year, doy, &mon, &day);
59 printf("%d %d %d\n", year, mon, day);
60
61 return EXIT_SUCCESS;
62}
63
64/*****************************************************************************/
65
66static void usage(
67 void) {
68 printf("\nJURASSIC calendar converter.\n\n");
69 printf("Convert year and day-of-year to a calendar date.\n\n");
70 printf("Usage:\n");
71 printf(" doy2day <year> <doy>\n\n");
72 printf("Arguments:\n");
73 printf(" <year> Calendar year.\n");
74 printf(" <doy> Day of year.\n\n");
75 printf("Output:\n");
76 printf(" Writes results to standard output.\n\n");
77 printf("Further information:\n");
78 printf(" Manual: https://slcs-jsc.github.io/jurassic/\n");
79}
int main(int argc, char *argv[])
Definition: doy2day.c:39
void doy2day(int year, int doy, int *mon, int *day)
Convert a day-of-year value to a calendar date.
Definition: jurassic.c:3378
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