Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Thank you
Param 12 4451
param wrote:
Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Yes. For the "C" locale the format for the %x specifier is %m/%d/%y. To
change this you need to call the setlocale function with LC_TIME as the
first argument and the desired locale as the second. To find out the format
of the category for the current locale pass a null pointer as the second
argument for setlocale. See sections 7.11 and 7.23.1 of the C Standard.
On Oct 4, 11:05 am, param <sparamesw...@gmail.comwrote:
Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Thank you
Param
Note: Always state the question in the body of your inquiry, not in
the heading. The question is about the use of strftime().
Just call strftime twice - once with %x (presumably you will display
this to the user), and once with whatever format is most convenient
for you to work with.
--
Fred Kleinschmidt
param wrote:
>
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format
of the output for interpreting it through program. Is there a way
to get the format of the %x directive (it differs across locales)?
For ex, default (locale is C), %x gives like %m/%d/%y.
>From N869, for printf:
[#8] The conversion specifiers and their meanings are:
.... snip ...
o,u,x,X The unsigned int argument is converted to unsigned
octal (o), unsigned decimal (u), or unsigned
hexadecimal notation (x or X) in the style dddd; the
letters abcdef are used for x conversion and the
letters ABCDEF for X conversion. The precision
specifies the minimum number of digits to appear; if
the value being converted can be represented in
fewer digits, it is expanded with leading zeros.
The default precision is 1. The result of
converting a zero value with a precision of zero is
no characters.
For strftime, again from N869:
7.23.3.5 The strftime function
Synopsis
[#1]
#include <time.h>
size_t strftime(char * restrict s,
size_t maxsize,
const char * restrict format,
const struct tm * restrict timeptr);
.... snip ...
[#3] Each conversion specifier is replaced by appropriate
characters as described in the following list. The
.... snip ...
%x is replaced by the locale's appropriate date
representation. [all specified in 7.23.1]
Which also suggests you should examine section 7.23.1.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
"CBFalconer" <cb********@yahoo.coma écrit dans le message de news: 47***************@yahoo.com...
param wrote:
>> I want to use %x as directive to get the locale specific date representation. But, at the same time, i want to know the format of the output for interpreting it through program. Is there a way to get the format of the %x directive (it differs across locales)? For ex, default (locale is C), %x gives like %m/%d/%y.
>>From N869, for printf:
[#8] The conversion specifiers and their meanings are:
... snip ...
o,u,x,X The unsigned int argument is converted to unsigned
octal (o), unsigned decimal (u), or unsigned
hexadecimal notation (x or X) in the style dddd; the
letters abcdef are used for x conversion and the
letters ABCDEF for X conversion. The precision
specifies the minimum number of digits to appear; if
the value being converted can be represented in
fewer digits, it is expanded with leading zeros.
The default precision is 1. The result of
converting a zero value with a precision of zero is
no characters.
For strftime, again from N869:
7.23.3.5 The strftime function
Synopsis
[#1]
#include <time.h>
size_t strftime(char * restrict s,
size_t maxsize,
const char * restrict format,
const struct tm * restrict timeptr);
... snip ...
[#3] Each conversion specifier is replaced by appropriate
characters as described in the following list. The
... snip ...
%x is replaced by the locale's appropriate date
representation. [all specified in 7.23.1]
Which also suggests you should examine section 7.23.1.
Why do you keep quoting from an obsolete draft (10 years old) and what does
printf have to do with the OP's question?
--
Chqrlie.
Charlie Gordon wrote:
"CBFalconer" <cb********@yahoo.coma écrit:
>param wrote:
>>> I want to use %x as directive to get the locale specific date representation. But, at the same time, i want to know the format of the output for interpreting it through program. Is there a way to get the format of the %x directive (it differs across locales)? For ex, default (locale is C), %x gives like %m/%d/%y.
>>>From N869, for printf:
[#8] The conversion specifiers and their meanings are:
... snip ...
o,u,x,X The unsigned int argument is converted to unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal notation (x or X) in the style dddd; the letters abcdef are used for x conversion and the letters ABCDEF for X conversion. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros. The default precision is 1. The result of converting a zero value with a precision of zero is no characters.
For strftime, again from N869:
7.23.3.5 The strftime function
Synopsis
[#1] #include <time.h> size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, const struct tm * restrict timeptr); ... snip ...
[#3] Each conversion specifier is replaced by appropriate characters as described in the following list. The
... snip ...
%x is replaced by the locale's appropriate date representation. [all specified in 7.23.1]
Which also suggests you should examine section 7.23.1.
Why do you keep quoting from an obsolete draft (10 years old) and
what does printf have to do with the OP's question?
a) Because it is the only one available in text format.
b) Because I didn't even notice the reference to strftime until I
had already prepared the answer, and thus left that answer and
extended it. :-)
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
Charlie Gordon said:
[in response to a couple of quotes from N869 from Chuck]
Why do you keep quoting from an obsolete draft (10 years old)
Since the text was word-for-word identical with ISO/IEC 9899:1999, what
difference does it make where he got it from? If you're going to complain
about obsolete drafts, fine, but please do so only when it actually makes
a difference.
<snip>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Oct 4, 11:27 pm, fred.l.kleinschm...@boeing.com wrote:
On Oct 4, 11:05 am, param <sparamesw...@gmail.comwrote:
Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Thank you
Param
Note: Always state the question in the body of your inquiry, not in
the heading. The question is about the use of strftime().
Just call strftime twice - once with %x (presumably you will display
this to the user), and once with whatever format is most convenient
for you to work with.
--
Fred Kleinschmidt
Hi
Thank you for your time.
Question was, If we use %x directive in strftime, it gives different
output in different locale and also it depends on the implementation
(differs across unix platforms).
Like,
locale ouput
en_US 10/05/07
ko 2007 Oct 10
Ja Oct 10 2007 (something similar)
I want to know the output format of %x directive for each locale
(through any interface/directive). I couldn't able to find it.
Thank you
Param
On Oct 4, 10:18 pm, param <sparamesw...@gmail.comwrote:
On Oct 4, 11:27 pm, fred.l.kleinschm...@boeing.com wrote:
On Oct 4, 11:05 am, param <sparamesw...@gmail.comwrote:
Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Thank you
Param
Note: Always state the question in the body of your inquiry, not in
the heading. The question is about the use of strftime().
Just call strftime twice - once with %x (presumably you will display
this to the user), and once with whatever format is most convenient
for you to work with.
--
Fred Kleinschmidt
Hi
Thank you for your time.
Question was, If we use %x directive in strftime, it gives different
output in different locale and also it depends on the implementation
(differs across unix platforms).
Like,
locale ouput
en_US 10/05/07
ko 2007 Oct 10
Ja Oct 10 2007 (something similar)
I want to know the output format of %x directive for each locale
(through any interface/directive). I couldn't able to find it.
Thank you
Param- Hide quoted text -
- Show quoted text -
The standard says that the %x format will produce an "appropriate
date representation for the locale", but does not specify what
"appropriate" should mean. So different implementations may
produce different results, as long as that rseult is "appropriate"
for the locale.
You don't say WHY you want this information, so it is very hard
for us to provide an answer. What is it that you are trying
to accomplish? Is it merely curiosity?
--
Fred L. Kleinschmidt
On Oct 5, 7:26 pm, fred.l.kleinschm...@boeing.com wrote:
On Oct 4, 10:18 pm, param <sparamesw...@gmail.comwrote:
On Oct 4, 11:27 pm, fred.l.kleinschm...@boeing.com wrote:
On Oct 4, 11:05 am, param <sparamesw...@gmail.comwrote:
Hi All,
I want to use %x as directive to get the locale specific date
representation. But, at the same time, i want to know the format of
the output for interpreting it through program. Is there a way to get
the format of the %x directive (it differs across locales)? For ex,
default (locale is C), %x gives like %m/%d/%y.
Thank you
Param
Note: Always state the question in the body of your inquiry, not in
the heading. The question is about the use of strftime().
Just call strftime twice - once with %x (presumably you will display
this to the user), and once with whatever format is most convenient
for you to work with.
--
Fred Kleinschmidt
Hi
Thank you for your time.
Question was, If we use %x directive in strftime, it gives different
output in different locale and also it depends on the implementation
(differs across unix platforms).
Like,
locale ouput
en_US 10/05/07
ko 2007 Oct 10
Ja Oct 10 2007 (something similar)
I want to know the output format of %x directive for each locale
(through any interface/directive). I couldn't able to find it.
Thank you
Param- Hide quoted text -
- Show quoted text -
The standard says that the %x format will produce an "appropriate
date representation for the locale", but does not specify what
"appropriate" should mean. So different implementations may
produce different results, as long as that rseult is "appropriate"
for the locale.
You don't say WHY you want this information, so it is very hard
for us to provide an answer. What is it that you are trying
to accomplish? Is it merely curiosity?
--
Fred L. Kleinschmidt
The problem is, our existing library (third party) prints the log
information using %x
directive, we want to display the log information between dates (like
search facility between dates) in our application. Since the date
format differs across the locales. We couldn't able to interpret the
dates. We can achieve the requirement by running the 'date' command
with the option +%x for different locale and store it in the
application. But it is a static solution. If we find out a interface/
directive to give the format of the %x directive, it would be helpful
and a dynamic solution.
Thank you
Param
param <sp**********@gmail.comwrites:
The problem is, our existing library (third party) prints the log
information using %x
directive, we want to display the log information between dates (like
search facility between dates) in our application. Since the date
format differs across the locales. We couldn't able to interpret the
dates. We can achieve the requirement by running the 'date' command
with the option +%x for different locale and store it in the
application. But it is a static solution. If we find out a interface/
directive to give the format of the %x directive, it would be helpful
and a dynamic solution.
Set the LC_TIME locale to "C" when using the third-party library.
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
param wrote:
On Oct 5, 7:26 pm, fred.l.kleinschm...@boeing.com wrote:
>On Oct 4, 10:18 pm, param <sparamesw...@gmail.comwrote:
>>On Oct 4, 11:27 pm, fred.l.kleinschm...@boeing.com wrote: On Oct 4, 11:05 am, param <sparamesw...@gmail.comwrote: Hi All, I want to use %x as directive to get the locale specific date representation. But, at the same time, i want to know the format of the output for interpreting it through program. Is there a way to get the format of the %x directive (it differs across locales)? For ex, default (locale is C), %x gives like %m/%d/%y. Thank you Param Note: Always state the question in the body of your inquiry, not in the heading. The question is about the use of strftime(). Just call strftime twice - once with %x (presumably you will display this to the user), and once with whatever format is most convenient for you to work with. -- Fred Kleinschmidt Hi Thank you for your time. Question was, If we use %x directive in strftime, it gives different output in different locale and also it depends on the implementation (differs across unix platforms). Like, locale ouput en_US 10/05/07 ko 2007 Oct 10 Ja Oct 10 2007 (something similar) I want to know the output format of %x directive for each locale (through any interface/directive). I couldn't able to find it. Thank you Param- Hide quoted text - - Show quoted text -
The standard says that the %x format will produce an "appropriate date representation for the locale", but does not specify what "appropriate" should mean. So different implementations may produce different results, as long as that rseult is "appropriate" for the locale.
You don't say WHY you want this information, so it is very hard for us to provide an answer. What is it that you are trying to accomplish? Is it merely curiosity? -- Fred L. Kleinschmidt
The problem is, our existing library (third party) prints the log
information using %x
directive, we want to display the log information between dates (like
search facility between dates) in our application. Since the date
format differs across the locales. We couldn't able to interpret the
dates. We can achieve the requirement by running the 'date' command
with the option +%x for different locale and store it in the
application. But it is a static solution. If we find out a interface/
directive to give the format of the %x directive, it would be helpful
and a dynamic solution.
Thank you
Param
Instead of the '%x' macro, use simpler things. '%d/%m/%y' for example.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
param wrote:
<snip>
The problem is, our existing library (third party) prints the log
information using %x directive, we want to display the log
information between dates (like search facility between dates)
in our application. Since the date format differs across the locales.
We couldn't able to interpret the dates. We can achieve the
requirement by running the 'date' command with the option +%x
for different locale and store it in the application. But it is a static
solution. If we find out a interface/directive to give the format of the
%x directive, it would be helpful and a dynamic solution.
If you call the setlocale function with LC_TIME and a null pointer as
the
first and second arguments respectively, a pointer to the string
associated
with the category, (here LC_TIME), for the current locale is returned.
How you use this to solve your problem is upto you. Personally I'd try
Michal Nazarewicz's suggestion. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kevininstructor |
last post by:
The following was copied from a web site for learning formatting.
Dim myInt As Integer = 100
Dim FormatPrice As String = String.Format("Price = |{0,10:c }|", myInt)
Console.WriteLine(FormatPrice)...
|
by: Servé Lau |
last post by:
suppose I want to use sscanf get the functionname from a function prototype.
Is the following format string correct then?
char funcname;
char *p = "func(void)";
sscanf(p, "%s", funcname);...
|
by: Donal McWeeney |
last post by:
Hi,
Is there a way to specify on the predefined format strings like P and N that
you want displayed all the decimals in the number...
for example
3 will display 3
2.1 will display 2.1...
|
by: MM |
last post by:
Hi,
I have a param class containg these vars:-
string key; // eg: "WN"
object value; // eg: 1.2
string format; // eg "F2"
and I output these to a StreamWriter using
...
|
by: Eddy Soeparmin |
last post by:
Hi,
I need to display a DateTime field in 'mm/dd/yyyy' in a DataGrid.. On
myGrid1 - Properties - Columns - myColumn1 - Text format string:
I tried to put 'mm/dd/yyyy' in there and it displays...
|
by: James |
last post by:
vb.net 2003
i used console.writeline to output to screen.
eg
console.writeline ("test1 : " & vbtab & v_test1)
console.writeline ("test2 : " & vbtab & v_test2)
etc etc
result becomes
|
by: stathisgotsis |
last post by:
Hello everyone,
Trusting K&R2 i thought until recently that spaces are ignored in
scanf's format string. Reading arguments to the contrary confused me a
little. So i now ask:
Is...
|
by: Tony Girgenti |
last post by:
Hello.
Trying to develop VS2005, SP1 windows form VB program.
When i try a statement like below and the data is "24.95", without the
quotes of course, regPriceString equals "000000000025+" .
...
|
by: moondaddy |
last post by:
I need to format a string to it always has 2 digits in it. I'm getting the
month like this:
DateTime.Now.Month.ToString()
Right now since it's August, this returns a string of "8", however, I...
|
by: Andrus |
last post by:
How to create format string for decimal data type
which shows blank for zero and default format otherwize ?
I tried format string "f;f;#" but this shows f for nonzero numbers.
Andrus.
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |