rfc1123

Looking to build some regex to validate domain names (RFC 952/ RFC 1123)

旧巷老猫 提交于 2019-12-13 18:33:45
问题 One of our clients validates email addresses in their own software prior to firing it via an API call to our system. The issue is however that their validation rules do not match those our system, therefore they are parsing and accepting addresses which break our rules. This is causing lots of failed calls. They are parsing stuff like "dave@-whatever.com", this goes against RFC 952/RFC 1123 rules as it begins with a hyphen. They have asked that we provide them with our regex list so they can

DateTime to RFC-1123 gives inaccurate timezone

烂漫一生 提交于 2019-12-10 18:59:49
问题 If I get the RFC-1123 formatted date of a DateTime object, it gives the current local time, but gives the timezone as GMT (which is inaccurate). DateTime.Now.ToString("r"); returns Fri, 12 Feb 2010 16:23:03 GMT At 4:23 in the afternoon, but my timezone is UTC+10 (plus, we're currently observing daylight saving time). Now, I can get a return value that's "correct" by converting to UTC first: DateTime.UtcNow.ToString("r"); returns Fri, 12 Feb 2010 05:23:03 GMT However, ideally, I'd like to get

Parsing RFC1123 formatted dates in C#, .Net 4.0

丶灬走出姿态 提交于 2019-11-26 17:23:53
问题 I am trying to parse dates in RFC1123 format (Thu, 21 Jan 2010 17:47:00 EST). Here is what I tried but none worked: DateTime Date = DateTime.Parse(dt); DateTime Date = DateTime.ParseExact(dt, "r", null); 回答1: Have you tried something like: string dateString, format; DateTime result; CultureInfo provider = CultureInfo.InvariantCulture; dateString = "Thu, 21 Jan 2010 17:47:00 EST"; format = "ddd, dd MMM yyyy hh:mm:ss EST"; result = DateTime.ParseExact(dateString, format, provider); Console