BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BCB6 strftime()

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students)
View previous topic :: View next topic  
Author Message
Roger
Guest





PostPosted: Fri Mar 16, 2007 9:29 pm    Post subject: BCB6 strftime() Reply with quote



I am using:

strptime("2007-03-16 13:14:15","%Y-%m-%d %T",&tmTime);

strftime(szMsg,40,"%Y-%m-%d %T %I%p",&tmTime);

szMsg = "2007-03-16 13:14:15 01PM" which is expected but I don't want
the leading '0' in '01PM' so I tried using the information in the help file
which indicates the usage of '# 'to eliminate the '0' as per:

strftime(szMsg,40,"%Y-%m-%d %T %#I%p",&tmTime);
but I still get:

szMsg = "2007-03-16 13:14:15 01PM"

how do I get rid of the leading '0' in '01PM' ?

As an aside what is the "flag" that is referred to with respect to "%#p"
in strftime?

Roger
Back to top
Roger
Guest





PostPosted: Sat Mar 17, 2007 2:56 am    Post subject: Re: BCB6 strftime() Reply with quote



Also,

strptime("2007-03-16 4:14:15PM","%Y-%m-%d %I:%M:%S%p",&tmTime);

this doesn't work unless there is a space before the 'PM' like so:

strptime("2007-03-16 4:14:15 PM","%Y-%m-%d %I:%M:%S %p",&tmTime);

Is that the way it is supposed to work, if so, where in the
documentation does it say so?

Roger
Back to top
Liz
Guest





PostPosted: Sat Mar 17, 2007 4:39 am    Post subject: Re: BCB6 strftime() Reply with quote



Roger wrote:

Quote:
Is that the way it is supposed to work, if so, where in the
documentation does it say so?

Yes

--
liz
Back to top
Roger
Guest





PostPosted: Sat Mar 17, 2007 5:52 am    Post subject: Re: BCB6 strftime() Reply with quote

Liz wrote:
Quote:
Roger wrote:


Is that the way it is supposed to work, if so, where in the
documentation does it say so?


Yes


Where is the related documentation, help files, etc that describe that

this is the way it is supposed to work for BCB 6?
Back to top
Liz
Guest





PostPosted: Sat Mar 17, 2007 6:24 am    Post subject: Re: BCB6 strftime() Reply with quote

Roger wrote:

Quote:
Where is the related documentation, help files, etc that describe
that this is the way it is supposed to work for BCB 6?

What's the help say?

--
liz
Back to top
Roger
Guest





PostPosted: Sat Mar 17, 2007 6:40 am    Post subject: Re: BCB6 strftime() Reply with quote

Liz wrote:
Quote:
Roger wrote:


Where is the related documentation, help files, etc that describe
that this is the way it is supposed to work for BCB 6?


What's the help say?


As you can see from the following, nothing relevant, at least that I can

see:


Header File

time.h

Category

Time and Date Routines

Prototype

size_t strftime(char *s, size_t maxsize, const char *fmt, const struct
tm *t);

size_t wcsftime(wchar_t *s, size_t maxsize, const wchar_t *fmt, const
struct tm *t);

Description

Formats time for output.

strftime formats the time in the argument t into the array pointed to by
the argument s according to the fmt specifications. All ordinary
characters are copied unchanged. No more than maxsize characters are
placed in s.

The time is formatted according to the current locale's LC_TIME category.

Return Value

On success, strftime returns the number of characters placed into s.

On error (if the number of characters required is greater than maxsize),
strftime returns 0.


The following table describes the ANSI-defined specifiers for the format
string used with strftime.

Format specifier Substitutes

%% Character %
%#% Character %, flag is ignored
%a Abbreviated weekday name
%#a Abbreviated weekday name, flag is ignored
%A Full weekday name
%#A Full weekday name, flag is ignored
%b Abbreviated month name
%#b Abbreviated month name, flag is ignored
%B Full month name
%#B Full month name, flag is ignored
%c Date and time
%#c Long date and time representation, appropriate for current
locale. For example: Tuesday, March 14, 1995, 12:41:29
%d Two-digit day of month (01 - 31)

%#d Two-digit day of month, remove leading zeros (if any)
%H Hour of the day, 24 hour day
%#H Hour of the day, 24 hour day, remove leading zeros (if any)
%I Two-digit hour, 12 hour day (01 - 12)
%#I Two-digit hour, 12 hour day, remove leading zeros (if any)
%j Three-digit day of year (001 - 366)
%#j Three-digit day of year, remove leading zeros (if any)
%m Two-digit month as a decimal number (1 - 12)
%#m Two-digit month as a decimal number, remove leading zeros (if any)

%M 2-digit minute (00 - 59)
%#M 2-digit minute, remove leading zeros (if any)
%p AM or PM
%#p AM or PM, flag is ignored
%S Two-digit second (00 - 59)
%#S Two-digit second, remove leading zeros (if any)
%U Two-digit week number where Sunday is the first day of the week
(00 - 53)
%#U Two-digit week number where Sunday is the first day of the week,
remove leading zeros (if any)
%w Weekday where 0 is Sunday (0 - 6)
%#w Weekday where 0 is Sunday, remove leading zeros (if any)

%W Two-digit week number where Monday is the first day of week the
week (00 - 53)
%#W Two-digit week number where Monday is the first day of week the
week, remove leading zeros (if any)
%x Date
%#x Long date representation, appropriate to current locale. For
example: Tuesday, March 14, 1995
%X Time
%#X Time, flag is ignored
%y Two-digit year without century (00 to 99)
%#y Two-digit year without century, remove leading zeros (if any)
%Y Year with century
%#Y Year with century, remove leading zeros (if any)

%Z, %z Time zone name, or no characters if no time zone
%#Z Time zone name, or no characters if no time zone, flag is ignored
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.