Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS AAR SV ctime ctime.c)
|
||||
NGL_ADD_EXECUTABLE(WS AAR SV stime stime.c)
|
||||
NGL_INSTALL_TARGET(ctime)
|
||||
NGL_INSTALL_TARGET(stime)
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
/* --------------------------------------------------------------------
|
||||
/ $HeadURL$
|
||||
/ --------------------------------------------------------------------
|
||||
/ --------------------------------------------------------------------
|
||||
/ COPYRIGHT (C) 1999: STN ATLAS ELEKTRONIK GMBH, D-28305 BREMEN
|
||||
/ --------------------------------------------------------------------
|
||||
/
|
||||
/ HIER/ITEM : CSU: RP 5182 P 100 SRC 57500
|
||||
/ BRIEF DESC: Zeitwandelroutinen
|
||||
/ AUTHOR : Norbert Thoden
|
||||
/ RELEASE :
|
||||
/ MODIF/STAT: 21.02.00
|
||||
/ ORIGIN REF:
|
||||
/
|
||||
/ Revision INFO:
|
||||
/ --------------
|
||||
/ $Revision$
|
||||
/ $Date$
|
||||
/ $Id$
|
||||
/
|
||||
/ LANGUAGE: C++ (Compiler: MipsPro C++ Version: 7.30)
|
||||
/
|
||||
/ PURPOSE:
|
||||
/ --------
|
||||
/ Zeitwandelroutinen
|
||||
/
|
||||
/ ERROR HANDLING:
|
||||
/ ---------------
|
||||
/ keine
|
||||
/
|
||||
*/
|
||||
|
||||
/*------------------ includes ----------------------------*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
printf("\nBitte die Zeit in sec mituebergeben!");
|
||||
printf("\nz. B. ctime %ld (Millisekunden sind auch erlaubt - wenn > 1000000000000 -> msec)\n", time(NULL));
|
||||
return 3;
|
||||
}
|
||||
|
||||
time_t clock;
|
||||
sscanf(argv[1], "%ld", &clock);
|
||||
if (clock > 1000000000000LL)
|
||||
clock /= 1000;
|
||||
|
||||
struct tm *tm = gmtime(&clock);
|
||||
printf("gmtime Zeit = %02d:", tm->tm_hour);
|
||||
printf("%02d:", tm->tm_min);
|
||||
printf("%02d ", tm->tm_sec);
|
||||
printf("Datum = %02d.", tm->tm_mday);
|
||||
printf("%02d.", (tm->tm_mon) + 1);
|
||||
printf("%02d\n", tm->tm_year + 1900);
|
||||
tm = localtime(&clock);
|
||||
printf("localtime Zeit = %02d:", tm->tm_hour);
|
||||
printf("%02d:", tm->tm_min);
|
||||
printf("%02d ", tm->tm_sec);
|
||||
printf("Datum = %02d.", tm->tm_mday);
|
||||
printf("%02d.", (tm->tm_mon) + 1);
|
||||
printf("%04d", tm->tm_year + 1900);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
/* --------------------------------------------------------------------
|
||||
/ $HeadURL$
|
||||
/ --------------------------------------------------------------------
|
||||
/ --------------------------------------------------------------------
|
||||
/ COPYRIGHT (C) 1999: STN ATLAS ELEKTRONIK GMBH, D-28305 BREMEN
|
||||
/ --------------------------------------------------------------------
|
||||
/
|
||||
/ HIER/ITEM : CSU: RP 5182 P 100 SRC 57501
|
||||
/ BRIEF DESC: Zeitwandelroutinen
|
||||
/ AUTHOR : Norbert Thoden
|
||||
/ RELEASE :
|
||||
/ MODIF/STAT: dd.mm.yy
|
||||
/ ORIGIN REF:
|
||||
/
|
||||
/ Revision INFO:
|
||||
/ --------------
|
||||
/ $Revision$
|
||||
/ $Date$
|
||||
/ $Id$
|
||||
/
|
||||
/ LANGUAGE: C++ (Compiler: MipsPro C++ Version: 7.30)
|
||||
/
|
||||
/ PURPOSE:
|
||||
/ --------
|
||||
/ Zeitwandelroutinen
|
||||
/
|
||||
/ ERROR HANDLING:
|
||||
/ ---------------
|
||||
/ keine
|
||||
/
|
||||
*/
|
||||
|
||||
/*------------------ includes ----------------------------*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
time_t time_l;
|
||||
struct tm time_str;
|
||||
char dummy[5];
|
||||
int jahr;
|
||||
|
||||
if (argc == 2 && strcmp(argv[1], "now") == 0)
|
||||
{
|
||||
printf("Sekunden: %ld\n", time(NULL));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* zu wenig Uebergabeparameter */
|
||||
if (argc <= 2)
|
||||
{
|
||||
printf("\nBitte das Datum und die Zeit mit uebergeben!");
|
||||
printf("\nz.B. 26.03.1997 10:10:00\n\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (argv[1][2] != '.' || argv[1][5] != '.' || argv[2][2] != ':' || argv[2][5] != ':' ||
|
||||
strlen(argv[1]) != 10)
|
||||
{
|
||||
/* Ueberpruefen der Eingabeparameter */
|
||||
printf("\nFehler bei der Datums- oder Uhrzeiteingabe!");
|
||||
printf("\nGefordertes Format : 26.03.1997 10:10:00\n\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
sprintf(dummy, "%c%c%c%c", argv[1][6], argv[1][7], argv[1][8], argv[1][9]);
|
||||
jahr = atoi(dummy) - 1900;
|
||||
|
||||
/* Eintragen des Datums und der Uhrzeit in die tm-Struktur */
|
||||
time_str.tm_mday = 10 * ((int)(argv[1][0]) - 48)
|
||||
+ (int)(argv[1][1]) - 48;
|
||||
time_str.tm_mon = 10 * ((int)(argv[1][3]) - 48)
|
||||
+ (int)(argv[1][4]) - 49;
|
||||
time_str.tm_year = jahr;
|
||||
time_str.tm_hour = 10 * ((int)(argv[2][0]) - 48)
|
||||
+ (int)(argv[2][1]) - 48;
|
||||
time_str.tm_min = 10 * ((int)(argv[2][3]) - 48)
|
||||
+ (int)(argv[2][4]) - 48;
|
||||
time_str.tm_sec = 10 * ((int)(argv[2][6]) - 48)
|
||||
+ (int)(argv[2][7]) - 48;
|
||||
time_str.tm_isdst = 0;
|
||||
|
||||
/* tm_mday - Plausibilitaetstest */
|
||||
if (time_str.tm_mday < 1 || time_str.tm_mday > 31)
|
||||
{
|
||||
printf("\nTagesangabe nicht korrekt!\n\n");
|
||||
return 1;
|
||||
}
|
||||
/* tm_mon - Plausibilitaetstest */
|
||||
if (time_str.tm_mon < 0 || time_str.tm_mon > 11)
|
||||
{
|
||||
printf("\nMonatsangabe nicht korrekt!\n\n");
|
||||
return 1;
|
||||
}
|
||||
/* tm_hour - Plausibilitaetstest */
|
||||
if (time_str.tm_hour < 0 || time_str.tm_hour > 23)
|
||||
{
|
||||
printf("\nStundenangabe nicht korrekt!\n\n");
|
||||
return 1;
|
||||
}
|
||||
/* tm_min - Plausibilitaetstest */
|
||||
if (time_str.tm_min < 0 || time_str.tm_min > 59)
|
||||
{
|
||||
printf("\nMinutenangabe nicht korrekt!\n\n");
|
||||
return 1;
|
||||
}
|
||||
/* tm_sec - Plausibilitaetstest */
|
||||
if (time_str.tm_sec < 0 || time_str.tm_sec > 59)
|
||||
{
|
||||
printf("\nSekundenangabe nicht korrekt!\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((time_l = mktime(&time_str)) == -1)
|
||||
printf("\nKalenderzeit konnte nicht bestimmt werden!\n\n");
|
||||
else
|
||||
printf("\nSekunden: %ld \n\n", time_l);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user