mirror of
https://github.com/theoleuthardt/learningC.git
synced 2026-06-13 09:37:53 +00:00
Initial commit
This commit is contained in:
commit
826d4c8c9d
81 changed files with 7268 additions and 0 deletions
28
uebung8/aufgabe7.c
Normal file
28
uebung8/aufgabe7.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
int secondsSinceMonthBegin(){
|
||||
// Aktuelle Zeit erhalten
|
||||
time_t currentTime;
|
||||
time(¤tTime);
|
||||
|
||||
// Lokale Zeitzone des Systems erhalten
|
||||
struct tm *localTime;
|
||||
localTime = localtime(¤tTime);
|
||||
|
||||
int secondsSinceMonthBegin = localTime->tm_sec + // Sekunden
|
||||
localTime->tm_min * 60 + // Minuten
|
||||
localTime->tm_hour * 3600 + // Stunden
|
||||
(localTime->tm_mday - 1) * 86400; // Tage
|
||||
|
||||
// Berücksichtigung der Zeitzone
|
||||
secondsSinceMonthBegin += timezone;
|
||||
|
||||
return secondsSinceMonthBegin;
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Ausgabe der Sekunden seit Monatsbeginn:
|
||||
printf("Anzahl der Sekunden seit Monatsbeginn: %d", secondsSinceMonthBegin());
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue