mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Changed the algorithm that calculates the number of days that have passed
so far as used by the the __convert_time() function and the conversion code in strftime(). - Also changed the algorithm used by strftime() to produce the week numbers (the '%U' and '%W' format specifiers). The new method is much simpler than the old one. - Made the code that converts a 'time_t' value into the 'struct DateStamp', as used by strftime() and utime(), into its own function. This also fixes a bug in the code strftime() would use which was completely unaware of the local time zone settings. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14815 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.68k,v 1.22 2005-01-26 18:41:38 obarthel Exp $
|
||||
# $Id: GNUmakefile.68k,v 1.23 2005-01-29 18:05:13 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -364,9 +364,11 @@ C_LIB = \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
time_gmtime_r.o \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.os4,v 1.22 2005-01-26 18:41:39 obarthel Exp $
|
||||
# $Id: GNUmakefile.os4,v 1.23 2005-01-29 18:05:13 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -366,9 +366,11 @@ C_LIB = \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
time_gmtime_r.o \
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "amiga.lib 1.186"
|
||||
#define VSTRING "amiga.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: amiga.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "amiga.lib 1.187"
|
||||
#define VSTRING "amiga.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: amiga.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "c.lib 1.186"
|
||||
#define VSTRING "c.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: c.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "c.lib 1.187"
|
||||
#define VSTRING "c.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: c.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
c.lib 1.187 (29.1.2005)
|
||||
|
||||
- The default console output window opened when a program is launched
|
||||
from Workbench would open and stay open. This was not intended to
|
||||
happen and is a side-effect of the new stdio initialization code which
|
||||
@ -18,6 +20,19 @@
|
||||
strftime() and asctime_r(). This one isn't sensitive to the effects of
|
||||
adding/subtracting the local time zone.
|
||||
|
||||
- Changed the algorithm that calculates the number of days that have passed
|
||||
so far as used by the the __convert_time() function and the conversion
|
||||
code in strftime().
|
||||
|
||||
- Also changed the algorithm used by strftime() to produce the week numbers
|
||||
(the '%U' and '%W' format specifiers). The new method is much simpler
|
||||
than the old one.
|
||||
|
||||
- Made the code that converts a 'time_t' value into the 'struct DateStamp',
|
||||
as used by strftime() and utime(), into its own function. This also
|
||||
fixes a bug in the code strftime() would use which was completely
|
||||
unaware of the local time zone settings.
|
||||
|
||||
|
||||
c.lib 1.186 (14.1.2005)
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "debug.lib 1.186"
|
||||
#define VSTRING "debug.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: debug.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "debug.lib 1.187"
|
||||
#define VSTRING "debug.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: debug.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "m.lib 1.186"
|
||||
#define VSTRING "m.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "m.lib 1.187"
|
||||
#define VSTRING "m.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "m881.lib 1.186"
|
||||
#define VSTRING "m881.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m881.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "m881.lib 1.187"
|
||||
#define VSTRING "m881.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: m881.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: macros.h,v 1.6 2005-01-24 10:25:46 obarthel Exp $
|
||||
* $Id: macros.h,v 1.7 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -67,10 +67,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define MILLION (1000000)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define NUM_ENTRIES(t) (sizeof(t) / sizeof(t[0]))
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "net.lib 1.186"
|
||||
#define VSTRING "net.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: net.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "net.lib 1.187"
|
||||
#define VSTRING "net.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: net.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: smakefile,v 1.17 2005-01-26 18:41:39 obarthel Exp $
|
||||
# $Id: smakefile,v 1.18 2005-01-29 18:05:14 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -472,9 +472,11 @@ TIME_OBJ = \
|
||||
time_clock.o \
|
||||
time_converttime.o \
|
||||
time_convert_datestamp.o \
|
||||
time_convert_time.o \
|
||||
time_ctime.o \
|
||||
time_ctime_r.o \
|
||||
time_data.o \
|
||||
time_days_per_date.o \
|
||||
time_difftime.o \
|
||||
time_gettimeofday.o \
|
||||
time_gmtime.o \
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "stack.lib 1.186"
|
||||
#define VSTRING "stack.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: stack.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "stack.lib 1.187"
|
||||
#define VSTRING "stack.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: stack.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_converttime.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
* $Id: time_converttime.c,v 1.3 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -43,7 +43,6 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
DECLARE_UTILITYBASE();
|
||||
struct ClockData clock_data;
|
||||
struct tm * result;
|
||||
ULONG delta;
|
||||
|
||||
ENTER();
|
||||
|
||||
@ -62,8 +61,13 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
/* Now the local time offset will have to go. */
|
||||
seconds -= gmt_offset;
|
||||
|
||||
/* Convert the number of seconds into a more useful format. */
|
||||
Amiga2Date(seconds, &clock_data);
|
||||
|
||||
/* The 'struct clockdata' layout and contents are very similar
|
||||
* to the 'struct tm' contents. We don't have to convert much,
|
||||
* except for the 'tm.tm_yday' field below.
|
||||
*/
|
||||
tm->tm_sec = clock_data.sec;
|
||||
tm->tm_min = clock_data.min;
|
||||
tm->tm_hour = clock_data.hour;
|
||||
@ -73,12 +77,8 @@ __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm)
|
||||
tm->tm_wday = clock_data.wday;
|
||||
tm->tm_isdst = -1;
|
||||
|
||||
clock_data.mday = 1;
|
||||
clock_data.month = 1;
|
||||
|
||||
delta = Date2Amiga(&clock_data);
|
||||
|
||||
tm->tm_yday = (seconds - delta) / (24 * 60 * 60);
|
||||
/* Now figure out how many days have passed since January 1st. */
|
||||
tm->tm_yday = __calculate_days_per_date(clock_data.year,clock_data.month,clock_data.mday) - __calculate_days_per_date(clock_data.year,1,1);
|
||||
|
||||
result = tm;
|
||||
|
||||
|
||||
56
library/time_days_per_date.c
Normal file
56
library/time_days_per_date.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* $Id: time_days_per_date.c,v 1.1 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This calculates the number of days that have passed up to the
|
||||
given date. */
|
||||
int
|
||||
__calculate_days_per_date(int year,int month,int day)
|
||||
{
|
||||
int result;
|
||||
|
||||
month = month + 9;
|
||||
year = year - 1 + (month / 12);
|
||||
month = (month % 12) * 306 + 5;
|
||||
|
||||
result = (year * 365) + (year / 4) - (year / 100) + (year / 400) + (month / 10) + day - 1;
|
||||
|
||||
return(result);
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_headers.h,v 1.7 2005-01-26 18:41:39 obarthel Exp $
|
||||
* $Id: time_headers.h,v 1.8 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -95,7 +95,9 @@ extern char * __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size);
|
||||
extern char * __number_to_string(unsigned int number,char * string,size_t max_len,size_t min_len);
|
||||
extern struct tm * __convert_time(ULONG seconds, LONG gmt_offset, struct tm * tm);
|
||||
extern time_t __convert_datestamp_to_time(const struct DateStamp * ds);
|
||||
extern BOOL __convert_time_to_datestamp(time_t time_value,struct DateStamp * ds);
|
||||
extern int __calculate_weekday(int year,int month,int day);
|
||||
extern int __calculate_days_per_date(int year,int month,int day);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time_strftime.c,v 1.4 2005-01-26 18:41:39 obarthel Exp $
|
||||
* $Id: time_strftime.c,v 1.5 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -103,15 +103,12 @@ store_string_via_hook(const char * string,int len,struct Hook * hook)
|
||||
/****************************************************************************/
|
||||
|
||||
static void
|
||||
format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook * hook)
|
||||
format_date(const char *format,const struct tm *tm,struct Hook * hook)
|
||||
{
|
||||
struct tm other_tm;
|
||||
struct tm copy_tm;
|
||||
time_t other_time_value = 0; /* ZZZ compiler claims that this assignment is unnecessary. */
|
||||
char buffer[40];
|
||||
const char * str;
|
||||
char c;
|
||||
int i;
|
||||
|
||||
assert( format != NULL && tm != NULL && hook != NULL);
|
||||
|
||||
@ -200,7 +197,7 @@ format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook
|
||||
/* Locale specific date and time ("%a %b %d %H:%M:%S %Y"). */
|
||||
case 'c':
|
||||
|
||||
format_date("%a %b %d %H:%M:%S %Y",tm,time_value,hook);
|
||||
format_date("%a %b %d %H:%M:%S %Y",tm,hook);
|
||||
break;
|
||||
|
||||
/* Day of the month ("01"-"31"). */
|
||||
@ -234,13 +231,7 @@ format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook
|
||||
/* Day of the year ("001"-"366"). */
|
||||
case 'j':
|
||||
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mday = 1;
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
|
||||
__number_to_string((unsigned int)(other_time_value - time_value) / (24 * 60 * 60) + 1,buffer,sizeof(buffer),3);
|
||||
__number_to_string(1 + __calculate_days_per_date(tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday) - __calculate_days_per_date(tm->tm_year+1900,1,1),buffer,sizeof(buffer),3);
|
||||
store_string_via_hook(buffer,-1,hook);
|
||||
break;
|
||||
|
||||
@ -284,32 +275,7 @@ format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook
|
||||
*/
|
||||
case 'U':
|
||||
|
||||
/* Go back to January and find the first Sunday. */
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
for(i = 0 ; i < 7 ; i++)
|
||||
{
|
||||
other_tm.tm_mday = i+1;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
if(other_tm.tm_wday == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Store the number of weeks difference between
|
||||
* the given day and the first Sunday.
|
||||
*/
|
||||
if(time_value < other_time_value)
|
||||
{
|
||||
/* This must be week zero. */
|
||||
__number_to_string((unsigned int)0,buffer,sizeof(buffer),2);
|
||||
}
|
||||
else
|
||||
{
|
||||
__number_to_string((unsigned int)(time_value - other_time_value) / (7 * 24 * 60 * 60) + 1,buffer,sizeof(buffer),2);
|
||||
}
|
||||
|
||||
__number_to_string((tm->tm_yday + 7 - tm->tm_wday) / 7,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
break;
|
||||
|
||||
@ -327,45 +293,20 @@ format_date(const char *format,const struct tm *tm,time_t time_value,struct Hook
|
||||
*/
|
||||
case 'W':
|
||||
|
||||
/* Go back to January and find the first Monday. */
|
||||
other_tm = (*tm);
|
||||
other_tm.tm_mon = 0;
|
||||
|
||||
for(i = 0 ; i < 7 ; i++)
|
||||
{
|
||||
other_tm.tm_mday = i+1;
|
||||
|
||||
other_time_value = mktime(&other_tm);
|
||||
if(other_tm.tm_wday == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Store the number of weeks difference between
|
||||
* the given day and the first Monday.
|
||||
*/
|
||||
if(time_value < other_time_value)
|
||||
{
|
||||
/* This must be week zero. */
|
||||
__number_to_string((unsigned int)0,buffer,sizeof(buffer),2);
|
||||
}
|
||||
else
|
||||
{
|
||||
__number_to_string((unsigned int)(time_value - other_time_value) / (7 * 24 * 60 * 60) + 1,buffer,sizeof(buffer),2);
|
||||
}
|
||||
|
||||
__number_to_string((tm->tm_yday + 7 - ((tm->tm_wday + 6) % 7)) / 7,buffer,sizeof(buffer),2);
|
||||
store_string_via_hook(buffer,2,hook);
|
||||
break;
|
||||
|
||||
/* Locale-specific date ("%a %b %d, %Y"). */
|
||||
case 'x':
|
||||
|
||||
format_date("%a %b %d, %Y",tm,time_value,hook);
|
||||
format_date("%a %b %d, %Y",tm,hook);
|
||||
break;
|
||||
|
||||
/* Locale-specific time ("%H:%M:%S"). */
|
||||
case 'X':
|
||||
|
||||
format_date("%H:%M:%S",tm,time_value,hook);
|
||||
format_date("%H:%M:%S",tm,hook);
|
||||
break;
|
||||
|
||||
/* Year without century ("00"-"99"). */
|
||||
@ -436,8 +377,6 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
struct format_hook_data data;
|
||||
struct Hook hook;
|
||||
size_t result = 0;
|
||||
struct tm tm_copy;
|
||||
time_t time_value;
|
||||
|
||||
ENTER();
|
||||
|
||||
@ -465,15 +404,6 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
|
||||
if(maxsize > 0)
|
||||
{
|
||||
tm_copy = (*tm);
|
||||
|
||||
time_value = mktime(&tm_copy);
|
||||
if(time_value == (time_t)-1)
|
||||
{
|
||||
SHOWMSG("invalid time");
|
||||
goto out;
|
||||
}
|
||||
|
||||
data.buffer = s;
|
||||
data.max_size = maxsize-1;
|
||||
|
||||
@ -496,12 +426,25 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
if(__locale_table[LC_TIME] != NULL)
|
||||
{
|
||||
struct DateStamp ds;
|
||||
struct tm tm_copy;
|
||||
time_t time_value;
|
||||
|
||||
time_value -= UNIX_TIME_OFFSET;
|
||||
tm_copy = (*tm);
|
||||
|
||||
ds.ds_Days = time_value / (24 * 60 * 60);
|
||||
ds.ds_Minute = (time_value % (24 * 60 * 60)) / 60;
|
||||
ds.ds_Tick = (time_value % 60) * TICKS_PER_SECOND;
|
||||
time_value = mktime(&tm_copy);
|
||||
if(time_value == (time_t)-1)
|
||||
{
|
||||
SHOWMSG("invalid time");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Convert the number of seconds into a DateStamp, as to be
|
||||
submitted to the FormatDate() function below. */
|
||||
if(CANNOT __convert_time_to_datestamp(time_value,&ds))
|
||||
{
|
||||
SHOWMSG("time conversion to datestamp failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
assert( LocaleBase != NULL );
|
||||
|
||||
@ -509,7 +452,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm)
|
||||
}
|
||||
else
|
||||
{
|
||||
format_date(format,tm,time_value,&hook);
|
||||
format_date(format,tm,&hook);
|
||||
}
|
||||
|
||||
(*data.buffer) = '\0';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#define VERSION 1
|
||||
#define REVISION 186
|
||||
#define DATE "14.1.2005"
|
||||
#define VERS "unix.lib 1.186"
|
||||
#define VSTRING "unix.lib 1.186 (14.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: unix.lib 1.186 (14.1.2005)"
|
||||
#define REVISION 187
|
||||
#define DATE "29.1.2005"
|
||||
#define VERS "unix.lib 1.187"
|
||||
#define VSTRING "unix.lib 1.187 (29.1.2005)\r\n"
|
||||
#define VERSTAG "\0$VER: unix.lib 1.187 (29.1.2005)"
|
||||
|
||||
@ -1 +1 @@
|
||||
186
|
||||
187
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: utime_utime.c,v 1.4 2005-01-24 10:25:46 obarthel Exp $
|
||||
* $Id: utime_utime.c,v 1.5 2005-01-29 18:05:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -45,6 +45,10 @@
|
||||
#include "locale_headers.h"
|
||||
#endif /* _LOCALE_HEADERS_H */
|
||||
|
||||
#ifndef _TIME_HEADERS_H
|
||||
#include "time_headers.h"
|
||||
#endif /* _TIME_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
@ -80,28 +84,11 @@ utime(const char * path_name,const struct utimbuf * times)
|
||||
DateStamp format, as used by the SetFileDate() function. */
|
||||
if(times != NULL)
|
||||
{
|
||||
time_t seconds;
|
||||
|
||||
seconds = times->modtime;
|
||||
|
||||
/* The modification time has to lie within the AmigaOS epoch. */
|
||||
if(seconds < UNIX_TIME_OFFSET)
|
||||
if(CANNOT __convert_time_to_datestamp(times->modtime,&ds))
|
||||
{
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Adjust the modification time to the AmigaOS epoch. */
|
||||
seconds -= UNIX_TIME_OFFSET;
|
||||
|
||||
/*<2A>If possible, adjust the modification time to match the
|
||||
local time zone settings. */
|
||||
if(__default_locale != NULL)
|
||||
seconds -= 60 * __default_locale->loc_GMTOffset;
|
||||
|
||||
ds.ds_Days = (seconds / (24 * 60 * 60));
|
||||
ds.ds_Minute = (seconds % (24 * 60 * 60)) / 60;
|
||||
ds.ds_Tick = (seconds % 60) * TICKS_PER_SECOND;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user