From 9392454c583167937227f1fc90892791e712d570 Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Tue, 8 Apr 2008 08:46:56 +0200 Subject: adaint.h, adaint.c (__gnat_current_time_string): New routine. 2008-04-08 Hristian Kirtchev * adaint.h, adaint.c (__gnat_current_time_string): New routine. * g-timsta.adb, g-timsta.ads: New files. From-SVN: r134017 --- gcc/ada/adaint.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'gcc/ada/adaint.c') diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 72ebec7..62e540c 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2007, Free Software Foundation, Inc. * + * Copyright (C) 1992-2008, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -359,6 +359,30 @@ __gnat_current_time return (OS_Time) res; } +/* Return the current local time as a string in the ISO 8601 format of + "YYYY-MM-DD HH:MM:SS.SS". The returned string is 22 + 1 (NULL) characters + long. */ + +void +__gnat_current_time_string + (char *result) +{ + const char *format = "%Y-%m-%d %H:%M:%S"; + /* Format string necessary to describe the ISO 8601 format */ + + const time_t t_val = time (NULL); + + strftime (result, 22, format, localtime (&t_val)); + /* Convert the local time into a string following the ISO format, copying + at most 22 characters into the result string. */ + + result [19] = '.'; + result [20] = '0'; + result [21] = '0'; + /* The sub-seconds are manually set to zero since type time_t lacks the + precision necessary for nanoseconds. */ +} + void __gnat_to_gm_time (OS_Time *p_time, @@ -434,7 +458,8 @@ __gnat_symlink (char *oldpath ATTRIBUTE_UNUSED, /* Try to lock a file, return 1 if success. */ -#if defined (__vxworks) || defined (__nucleus__) || defined (MSDOS) || defined (_WIN32) +#if defined (__vxworks) || defined (__nucleus__) || defined (MSDOS) \ + || defined (_WIN32) /* Version that does not use link. */ -- cgit v1.1