473,763 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot parse an en-US date on a non-en-US system!

I have put my users through so much crap with this bug it is an absolute
shame.

I have a product that reads/writes RSS 2.0 documents, among other things.
The RSS 2.0 spec mandates an en-US style of date formatting (RFC 822). I
have been using a variation of RFC 1123 (just change the time zone to an
offset, i.e. "-0800"). It seems to be writing okay, but it's failing to
parse.

I've tried changing the regional & language settings in my Windows XP
control panel so that I could test, but after getting it to work that way, a
guy from Pakistan (I think?) is still getting date parsing problems.

Here's what I've got. See ParseDateTime() below.

/// <summary>
/// Currently, this method simply calls DateToRFC1123St ring(),
/// but then changes the time zone to "+/-####", i.e. "-0700".
/// </summary>
public static string DateToRFC822Str ing(DateTime dt, bool
fromLocalTimeZo ne) {
string dts = DateToRFC1123St ring(dt, false);
if (fromLocalTimeZ one) {
string offset = MiscUtil.SysDTO ffset.ToString( );
offset = offset.Replace( ":", "").Replace (" ", "");
if (offset.Substri ng(0, 1) != "-") {
if (offset.Substri ng(0, 1) == "+") {
offset = offset.Substrin g(0, 5);
} else {
offset = "+" + offset.Substrin g(0, 4);
}
} else {
offset = offset.Substrin g(0, 5);
}
dts = dts.Replace("GM T", offset);
}
return dts;
}

public static TimeSpan SysDTOffset {
get {
return System.TimeZone .CurrentTimeZon e.GetUtcOffset( DateTime.Now);
}
}

/// <summary>
/// Converts a time zone (e.g. "PST") to an offset string (e.g. "-0700").
/// </summary>
/// <param name="tz">The time zone to convert.</param>
/// <returns>The offset string (e.g. "-0700").</returns>
public static string TimeZoneToOffse t(string tz) {
tz = tz.ToUpper().Tr im()
.Replace("PACIF IC", "PST")
.Replace("MOUNT AIN", "MST")
.Replace("CENTR AL", "CST")
.Replace("EASTE RN", "EST");
for (int i=0; i<TimeZones.Len gth; i++) {
if (((string)((str ing[])TimeZones.GetV alue(i)).GetVal ue(0)) == tz) {
return ((string)((stri ng[])TimeZones.GetV alue(i)).GetVal ue(1));
}
}
return
System.TimeZone .CurrentTimeZon e.GetUtcOffset( DateTime.Now).T oString()
.Replace(":", "").Substring(0 , 5);
}

public static string OffsetToTimeZon e(string offset) {
foreach (string[] tz in TimeZones) {
if (((string)tz.Ge tValue(1)) == offset) {
return (string)tz.GetV alue(0);
}
}
return "GMT";
}

public static string OffsetToTimeZon e(string offset, bool
isDaylightSavin gs) {
foreach (string[] tz in TimeZones) {
if (((string)tz.Ge tValue(1)) == offset) {
string tzs = (string)tz.GetV alue(0);
if (isDaylightSavi ngs) {
switch (tzs) {
case "PDT":
return tzs;
case "MDT":
return tzs;
case "CDT":
return tzs;
case "EDT":
return tzs;
case "MST":
return "PDT";
case "CST":
return "MDT";
case "EST":
return "CDT";
default:
return tzs;
}
} else {
return tzs;
}
//return;
//return (string)tz.GetV alue(0);
}
}
return "GMT";
}

public static string DateToRFC1123St ring(DateTime dt, bool
fromLocalTimeZo ne) {
if (fromLocalTimeZ one) {
dt = dt.ToUniversalT ime();
}
System.Globaliz ation.CultureIn fo ci = new
System.Globaliz ation.CultureIn fo("en-US", false);
string ret = dt.ToString(ci. DateTimeFormat. RFC1123Pattern, ci);
return ret;
}
/// <summary>
/// Parses dates with time zones in the following formats:
/// "Thu, 17 Jul 2003 12:35:18 PST",
/// "Thu, 17 Jul 2003 12:35:18 -0700".
/// Converts the time to the local time zone.
/// </summary>
/// <param name="dateTime" >The date/time to parse.</param>
/// <returns>A DateTime object</returns>
public static DateTime ParseDateTime(s tring dateTime) {
System.Globaliz ation.CultureIn fo ci = null;
try {
ci = new System.Globaliz ation.CultureIn fo("en-US", false);
return DateTime.Parse( dateTime,
ci,
System.Globaliz ation.DateTimeS tyles.AllowWhit eSpaces);
} catch (FormatExceptio n fex0) {
try {
fex0=fex0; // ignore
return DateTime.Parse( dateTime,
System.Globaliz ation.DateTimeF ormatInfo.Invar iantInfo,
System.Globaliz ation.DateTimeS tyles.AllowWhit eSpaces);

} catch (FormatExceptio n fex) {
try {
try {
string iso8601_date = dateTime;
ci = new System.Globaliz ation.CultureIn fo("en-US", false);
return DateTime.ParseE xact(
iso8601_date,
ci.DateTimeForm at.SortableDate TimePattern,
ci.DateTimeForm at);
} catch {}
string loc = fex.Message.Sub string(fex.Mess age.LastIndexOf (" "));
loc = loc.Substring(0 , loc.LastIndexOf ("."));
string tz = "";
if (loc.Trim() == "DateTime") {
tz = dateTime.Substr ing(dateTime.La stIndexOf(" ")).Trim();
dateTime = dateTime.Substr ing(0, dateTime.Length - tz.Length);
} else {
try {
int iLoc = int.Parse(loc);
tz = dateTime.Substr ing(iLoc);
tz = TimeZoneToOffse t(tz);
dateTime = dateTime.Substr ing(0, iLoc);
} catch {
}
}
ci = new System.Globaliz ation.CultureIn fo("en-US", false);
DateTime ret = DateTime.Parse( dateTime,
ci,
System.Globaliz ation.DateTimeS tyles.AllowWhit eSpaces);

// offset for time zone
if (tz.Length > 0) {
try {
if (tz.Length == 4 && tz.Substring(0, 1) != "-") {
try {
int.Parse(tz.Su bstring(0, 1));
tz = "+" + tz;
} catch {
}
}
if (tz.Length == 5 && tz.Substring(0, 1) == "-" ||
tz.Length == 5 && tz.Substring(0, 1) == "+") {
try {
int h = int.Parse(tz.Su bstring(1, 2));
int m = int.Parse(tz.Su bstring(3, 2));
if (tz.Substring(0 , 1) == "-") {
ret = ret.AddHours((h * -1) - SysDTOffset.Hou rs);
ret = ret.AddMinutes( (m * -1) - SysDTOffset.Min utes);
} else {
ret = ret.AddHours(h - SysDTOffset.Hou rs);
ret = ret.AddMinutes( m - SysDTOffset.Min utes);
}
} catch {
}
}
} catch {}
}

return ret;
} catch {
return new DateTime(0);
}
}
}
}

/// <summary>
/// An array of time zones
/// (e.g. new string[] {"PST", "-0700", "(US) Pacific Standard"}).
/// </summary>
public static string[][] TimeZones = new string[][] {
new string[] {"ACDT", "+1030", "Australian Central Daylight"},
new string[] {"ACST", "+0930", "Australian Central Standard"},
new string[] {"ADT", "-0300", "(US) Atlantic Daylight"},
new string[] {"AEDT", "+1100", "Australian East Daylight"},
new string[] {"AEST", "+1000", "Australian East Standard"},
new string[] {"AHDT", "-0900", "AHDT"},
new string[] {"AHST", "-1000", "AHST"},
new string[] {"AST", "-0400", "(US) Atlantic Standard"},
new string[] {"AT", "-0200", "Azores"},
new string[] {"AWDT", "+0900", "Australian West Daylight"},
new string[] {"AWST", "+0800", "Australian West Standard"},
new string[] {"BAT", "+0300", "Bhagdad"},
new string[] {"BDST", "+0200", "British Double Summer"},
new string[] {"BET", "-1100", "Bering Standard"},
new string[] {"BST", "-0300", "Brazil Standard"},
new string[] {"BT", "+0300", "Baghdad"},
new string[] {"BZT2", "-0300", "Brazil Zone 2"},
new string[] {"CADT", "+1030", "Central Australian Daylight"},
new string[] {"CAST", "+0930", "Central Australian Standard"},
new string[] {"CAT", "-1000", "Central Alaska"},
new string[] {"CCT", "+0800", "China Coast"},
new string[] {"CDT", "-0500", "(US) Central Daylight"},
new string[] {"CED", "+0200", "Central European Daylight"},
new string[] {"CET", "+0100", "Central European"},
new string[] {"CST", "-0600", "(US) Central Standard"},
new string[] {"EAST", "+1000", "Eastern Australian Standard"},
new string[] {"EDT", "-0400", "(US) Eastern Daylight"},
new string[] {"EED", "+0300", "Eastern European Daylight"},
new string[] {"EET", "+0200", "Eastern Europe"},
new string[] {"EEST", "+0300", "Eastern Europe Summer"},
new string[] {"EST", "-0500", "(US) Eastern Standard"},
new string[] {"FST", "+0200", "French Summer"},
new string[] {"FWT", "+0100", "French Winter"},
new string[] {"GMT", "-0000", "Greenwich Mean"},
new string[] {"GST", "+1000", "Guam Standard"},
new string[] {"HDT", "-0900", "Hawaii Daylight"},
new string[] {"HST", "-1000", "Hawaii Standard"},
new string[] {"IDLE", "+1200", "Internatio n Date Line East"},
new string[] {"IDLW", "-1200", "Internatio n Date Line West"},
new string[] {"IST", "+0530", "Indian Standard"},
new string[] {"IT", "+0330", "Iran"},
new string[] {"JST", "+0900", "Japan Standard"},
new string[] {"JT", "+0700", "Java"},
new string[] {"MDT", "-0600", "(US) Mountain Daylight"},
new string[] {"MED", "+0200", "Middle European Daylight"},
new string[] {"MET", "+0100", "Middle European"},
new string[] {"MEST", "+0200", "Middle European Summer"},
new string[] {"MEWT", "+0100", "Middle European Winter"},
new string[] {"MST", "-0700", "(US) Mountain Standard"},
new string[] {"MT", "+0800", "Moluccas"} ,
new string[] {"NDT", "-0230", "Newfoundla nd Daylight"},
new string[] {"NFT", "-0330", "Newfoundland"} ,
new string[] {"NT", "-1100", "Nome"},
new string[] {"NST", "+0630", "North Sumatra"},
new string[] {"NZ", "+1100", "New Zealand "},
new string[] {"NZST", "+1200", "New Zealand Standard"},
new string[] {"NZDT", "+1300", "New Zealand Daylight"},
new string[] {"NZT", "+1200", "New Zealand"},
new string[] {"PDT", "-0700", "(US) Pacific Daylight"},
new string[] {"PST", "-0800", "(US) Pacific Standard"},
new string[] {"ROK", "+0900", "Republic of Korea"},
new string[] {"SAD", "+1000", "South Australia Daylight"},
new string[] {"SAST", "+0900", "South Australia Standard"},
new string[] {"SAT", "+0900", "South Australia Standard"},
new string[] {"SDT", "+1000", "South Australia Daylight"},
new string[] {"SST", "+0200", "Swedish Summer"},
new string[] {"SWT", "+0100", "Swedish Winter"},
new string[] {"USZ3", "+0400", "USSR Zone 3"},
new string[] {"USZ4", "+0500", "USSR Zone 4"},
new string[] {"USZ5", "+0600", "USSR Zone 5"},
new string[] {"USZ6", "+0700", "USSR Zone 6"},
new string[] {"UT", "-0000", "Universal Coordinated"},
new string[] {"UTC", "-0000", "Universal Coordinated"},
new string[] {"UZ10", "+1100", "USSR Zone 10"},
new string[] {"WAT", "-0100", "West Africa"},
new string[] {"WET", "-0000", "West European"},
new string[] {"WST", "+0800", "West Australian Standard"},
new string[] {"YDT", "-0800", "Yukon Daylight"},
new string[] {"YST", "-0900", "Yukon Standard"},
new string[] {"ZP4", "+0400", "USSR Zone 3"},
new string[] {"ZP5", "+0500", "USSR Zone 4"},
new string[] {"ZP6", "+0600", "USSR Zone 5"}
};
Nov 16 '05
14 3688
The exception you describe would be because parseCulture is null. Try making
it en-US?

I'm going to make some subtle changes based on what you experimented ..

Jon

"Ed Courtenay" <re************ *************** **@edcourtenay. co.uk> wrote in
message news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Jon Davis wrote:
The date string in a test file for one of my guinea pig users is "Thu, 13 May 2004 15:54:25 +0200", which is what my app came up with in the
DateToRFC822Str ing() method (see first post in thread).

Sorry, there is no stack trace. I can and may have to rebuild it with the removal of a quiet try..catch, and have my guinea pig re-download and
re-test, but I have burdened him with like five rebuilds of my app for this bug and I'm so embarrassed..

... If that's the only way, it's the only way *sigh*.

Jon

Well, I hope this will help... ;)

Thread.CurrentT hread.CurrentCu lture = new CultureInfo("ur-PK");
string dateFormat =

CultureInfo.Inv ariantCulture.D ateTimeFormat.R FC1123Pattern.R eplace("'GMT'", "zzz");
string dateString = "Thu, 13 May 2004 15:54:25 +0200";
CultureInfo parseCulture = null;
parseCulture = CultureInfo.Inv ariantCulture;
DateTime dateTime = DateTime.ParseE xact(dateString .Replace("GMT",
"+0000"), dateFormat, parseCulture);
Console.WriteLi ne("{0:R}", dateTime);

If you comment out "parseCultu re = CultureInfo.Inv ariantCulture;" you'll
get an exception, otherwise this will work as expected.
--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk

Nov 16 '05 #11
Jon Davis wrote:
is InvariantCultur e based on en-US?


From MSDN:

"The CultureInfo.Inv ariantCulture property is neither a neutral nor a
specific culture. It is a third type of culture that is
culture-insensitive. It is associated with the English language but not
with a country or region. You can use InvariantCultur e in almost any
method in the System.Globaliz ation namespace that requires a culture.
However, you should use the invariant culture only for processes that
require culture-independent results, such as system services. In other
cases, it produces results that might be linguistically incorrect or
culturally inappropriate."

--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #12
Jon Davis wrote:
The exception you describe would be because parseCulture is null. Try making
it en-US?

I'm going to make some subtle changes based on what you experimented ..

Jon


Jon,

I've just looked through the code you provided, and I think I can see
where there's a potential problem.

You're parsing the error message provided by the FormatException to
determine the type of error thrown. In particular, you're assuming that
the message is going to be something like:

"The string was not recognized as a valid DateTime. There is a unknown
word starting at index 26."

or

"The string was not recognized as a valid DateTime."

and handling the last 'word' in the message; you cannot guarantee what
the format of the message will be, and bear in mind that the message
will change depending on the locale of the system. In other words, you
cannot guarantee that the exception is in English!

I'm fairly certain that this is where your problem lies.

--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #13
Ed Courtenay wrote:
Jon Davis wrote:
The exception you describe would be because parseCulture is null. Try
making
it en-US?

I'm going to make some subtle changes based on what you experimented ..

Jon


Jon,

I've just looked through the code you provided, and I think I can see
where there's a potential problem.

You're parsing the error message provided by the FormatException to
determine the type of error thrown. In particular, you're assuming that
the message is going to be something like:

"The string was not recognized as a valid DateTime. There is a unknown
word starting at index 26."

or

"The string was not recognized as a valid DateTime."

and handling the last 'word' in the message; you cannot guarantee what
the format of the message will be, and bear in mind that the message
will change depending on the locale of the system. In other words, you
cannot guarantee that the exception is in English!

I'm fairly certain that this is where your problem lies.


I've re-written your ParseDateTime function so that it doesn't rely on
the format of the FormatException message; feel free to use/abuse it!

I hope this helps...

public static DateTime ParseDateTime(s tring dateTime)
{
System.Globaliz ation.CultureIn fo ci = CultureInfo.Inv ariantCulture;

try
{
return DateTime.Parse( dateTime, ci, DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
try
{
return DateTime.ParseE xact(dateTime, new string[]
{ci.DateTimeFor mat.SortableDat eTimePattern,
ci.DateTimeForm at.RFC1123Patte rn}, ci, DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
string dateFormat =
ci.DateTimeForm at.RFC1123Patte rn.Replace("'GM T'", "zzz");
foreach(string[] entry in TimeZones)
{
if (dateTime.EndsW ith(entry[0]))
{
dateTime = String.Format(" {0}{1}", dateTime.Substr ing(0,
dateTime.Length - entry[0].Length), entry[1]);
break; }
}
try
{
return DateTime.ParseE xact(dateTime, dateFormat, ci,
DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
return DateTime.Now;
}
}
}
}
--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #14
Thanks, Ed!

The major change to be made was to pass the dateFormat param (with GMT'
changed to zzz) to ParseExact(), which you describe below, and my guinea pig
user reports that this change works (just before I got your e-mail). So
thanks very much, glad to see confirmation.

Jon

"Ed Courtenay" <re************ *************** **@edcourtenay. co.uk> wrote in
message news:eB******** ******@TK2MSFTN GP11.phx.gbl...
Ed Courtenay wrote:
Jon Davis wrote:
The exception you describe would be because parseCulture is null. Try
making
it en-US?

I'm going to make some subtle changes based on what you experimented ..

Jon


Jon,

I've just looked through the code you provided, and I think I can see
where there's a potential problem.

You're parsing the error message provided by the FormatException to
determine the type of error thrown. In particular, you're assuming that
the message is going to be something like:

"The string was not recognized as a valid DateTime. There is a unknown
word starting at index 26."

or

"The string was not recognized as a valid DateTime."

and handling the last 'word' in the message; you cannot guarantee what
the format of the message will be, and bear in mind that the message
will change depending on the locale of the system. In other words, you
cannot guarantee that the exception is in English!

I'm fairly certain that this is where your problem lies.


I've re-written your ParseDateTime function so that it doesn't rely on
the format of the FormatException message; feel free to use/abuse it!

I hope this helps...

public static DateTime ParseDateTime(s tring dateTime)
{
System.Globaliz ation.CultureIn fo ci = CultureInfo.Inv ariantCulture;

try
{
return DateTime.Parse( dateTime, ci, DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
try
{
return DateTime.ParseE xact(dateTime, new string[]
{ci.DateTimeFor mat.SortableDat eTimePattern,
ci.DateTimeForm at.RFC1123Patte rn}, ci, DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
string dateFormat =
ci.DateTimeForm at.RFC1123Patte rn.Replace("'GM T'", "zzz");
foreach(string[] entry in TimeZones)
{
if (dateTime.EndsW ith(entry[0]))
{
dateTime = String.Format(" {0}{1}", dateTime.Substr ing(0,
dateTime.Length - entry[0].Length), entry[1]);
break; }
}
try
{
return DateTime.ParseE xact(dateTime, dateFormat, ci,
DateTimeStyles. AllowWhiteSpace s);
}
catch (FormatExceptio n)
{
return DateTime.Now;
}
}
}
}
--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk

Nov 16 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
7509
by: Erik Bethke | last post by:
Hello All, I am getting an error of not well-formed at the beginning of the Korean text in the second example. I am doing something wrong with how I am encoding my Korean? Do I need more of a wrapper about it than simple quotes? Is there some sort of XML syntax for indicating a Unicode string, or does the Elementree library just not support reading of Unicode? here is my test snippet:
45
3052
by: Jamie Burns | last post by:
Hello, I realise that I just dont get this, but I cannot see the need for auto_ptr. As far as I have read, it means that if you create an object using an auto_ptr, instead of a raw pointer, then the object will get cleaned up when the method/function ends. Isn't this what happens if you just declare an object without using a pointer at all? Aren't these examples the same (I know they will not be, but I am hoping someone may explain to me...
22
872
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to tokenize the comma separated values.I used strtok function reading line by line using fgets.but it gives some weird behavior.It doesnot stripout the "" fully.Could any body have sample code for the same so that it will be helfful for my...
24
3173
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and their types. I would like to somehow store a reference to parsing operations in this array (such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc), so I can invoke the appropriate one without writing a long switch.
1
2039
by: Slavisa | last post by:
When I make my program on RedHat 9.0 everything goes fine, but when I try to make on Red Hat 7.2 I get following errors: logic2_msgcln.c:178: warning: initialization makes integer from pointer without a cast logic2_msgcln.c:178: initializer element is not constant logic2_msgcln.c:178: warning: data definition has no type or storage class logic2_msgcln.c:185: parse error before `void' logic2_msgcln.c:225: parse error before `('
6
6509
by: PHLICS_Admin | last post by:
Hi All, There are two network cards in one computer (named A) , and there is one network card in another computer(named B). On computer A: one network card is used to connect to internet, and the other network card is used in intranet whose ipaddress is 192.168.0.1 On computer B: the network card's ipaddress is 192.168.0.2. These two computer can connect to each other.
12
12174
by: ross | last post by:
The following gives an error: <?php $super-man=100; ?> Parse error: parse error, unexpected '=' in /test.php on line 2 I understand that the "-" sign is seen as an operator. is there a way to get around this? I need to have "-" in variable names.
0
2960
nightangel
by: nightangel | last post by:
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP. The problem i met now is i need to do a resuming for the file uploading if the client connection or server connection is down. E.g: Sunset.jpg (500KB) when i upload until half of it, (332KB in the server) and unplug my connection, it will looping and try to connect to the server, after...
0
1116
by: Debajit Adhikary | last post by:
I'm writing a SAX parser using Python and need to parse XML with entity references. <tag>&lt;&gt;</tag> Only the last entity reference gets parsed. Why are startEntity() and endEntity() never called? I'm using the following code: http://pastie.textmate.org/62610
2
6658
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI Week5MortgageLogic allint = logic.allInterest(amount, term, rate); Week5MortgageGUI.java:152:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI
0
9563
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.