Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

today.c 681 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  1. /* $Id$
  2. *
  3. * called by cmake to obtain date at build time
  4. */
  5. #include <stdio.h>
  6. #include <time.h>
  7. #define BUFSIZE 32
  8. int main () {
  9. char today_string[BUFSIZE];
  10. /* obtain current time as time since epoch */
  11. time_t clock = time (NULL);
  12. /* convert time since epoch to calendar time expressed as local time */
  13. struct tm *p_time = localtime (&clock);
  14. /* convert tm object to custom textual representation YYYY;mm;dd;Mmm*/
  15. size_t result = strftime(today_string, BUFSIZE, "%Y;%m;%d;%B", p_time);
  16. if ( result ) {
  17. /* success, print date string */
  18. printf ("%s", today_string);
  19. return 0;
  20. }
  21. /* on error, print dummy */
  22. printf ("1313;13;13;Undecember");
  23. return -1;
  24. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...