« first day (4113 days earlier)      last day (827 days later) » 

mr5
7:24 AM
@Freerey middle ware
who invented that fancy name though?
it's dota time for me now yet these squirrels haven't woken up yet.
 
7:58 AM
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
8:14 AM
Goodm orning
 
 
1 hour later…
9:22 AM
where are from ?all
I am chinese
2
 
9:38 AM
Planet earth
 
10:03 AM
Hi chinese, I am Wietlol
 
10:33 AM
--!
Here is 18:33
I need work overtime
can you give my answers a vote up?
TTTTTTTTTTTTTTTTTTTTThanks
 
11:12 AM
do your answers deserve an upvote?
 
 
2 hours later…
1:18 PM
That was bot-level interaction, but who would be so crazy and build a farm bot just for SO chat?
 
@Never.More I'm from Indiana :0
 
heh, bot level interaction
 
mr5
You mean India?
 
dont make me laugh :D
 
@mr5 no ofc not :D
 
1:31 PM
in Sandbox, Oct 1 '20 at 14:31, by Wietlol
now die
@Squirrelkiller that is bot level interaction
 
 
3 hours later…
4:37 PM
I want to manipulate some ISO 8601 date strings in C#. More specifically I want to take in an string, try to see if it's ISO formatted and strip it to date only. E.g.:
"2022-01-19" -> "2022-01-19"
"2022-01-19T10:00:00" -> "2022-01-19"
"2022-01-19 15:00:00Z" -> "2022-01-19"
 
[Squirrel in Training] Sounds like a job for .SubString
 
I can't seem to find a good way to do it with the regular DateTime methods. TryParse with CultureInfo.InvariantCulture seems too lenient and accepts "10/01/2022" converting it to November. While TryParseExact requires me to supply every possible valid format and fails, for example, if I have specified yyyy-MM-ddTHH but I get the value without T as separator.
So, yeah - I was wondering if there is a non-string manipulation/non-regex way to verify that.
Also, just in case - if for any reason the string fails to be recognised as date, I'd want to return it as-is.
 
4:59 PM
either use regex or parse by a list of patterns
I have used both
 
DateTime.ParseExact(txt, new string[] {"s", "u"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None)
s/u is for ISO8601 with/without the T
 
basically
allPatterns
    .Select(format => TryParseDateTime(value, format))
    .WhereIsSuccess()
    .FindFirst()
    .Map(Format)
    .OrElse(value)
luckily for you, almost none of these functions exist in .net
 
Not a fan of the list of patterns. I want to make sure I get a reasonable sub-section of the formats: yyyy-MM-dd, yyyy-MM-ddTHH, yyyy-MM-ddTHH, yyyy-MM-ddTHH:mm, yyyy-MM-ddTHH:mm:ss, yyyy-MM-ddTHH:mm:ssZ, yyyy-MM-ddTHH:mm:ss.zzZ, etc
Also, will fail if the string starts with a whitespace.
 
then regex prefix
 
I might settle for regex. I just hoped there was a more standard way
 
5:02 PM
^\d{4}-\d{2}-\d{2}
you are doing a very non-standard operation
you shouldnt expect a standard solution
 
"match a sub-section of this date format" is not that non-standard
Or "don't match random stuff"
As DateTime.TryParse apparently does.
 
"get a date part of a string that may or may not start with a certain format"
 
I mean, it's ISO format. It should start with a date. Maybe there is a whitespace there but the format is quite known.
 
if you are sure it is an ISO date, then just use substring
 
I mean...that's the problem - I can't be sure. I am reasonably confident but just in case it doesn't match, I want to leave it as-is.
If it's "10/01/2020" I'm happy for this to fail and to forward that string and let somebody else try to figure it out. But if I get a date or date and time, I need just the date part.
"Parse as ISO format" shouldn't be a strange thing to ask for even. Some of the optional parts of it are, you know, optional. Like the time. If you include a time part, you can have hour and minutes, or also trailing seconds, or also trailing milliseconds, or also trailing time zone information.
That's all part of the ISO standard.
 
5:11 PM
public DateTime AsDateTime() =>
    ListOf(
            "yyyy-MM-dd'T'HH:mm:ss.fff",
            "yyyy-MM-dd'T'HH:mm:ss",
            "yyyy-MM-dd'T'HH:mm",
            "yyyy-MM-dd",
            "HH:mm:ss.fff",
            "HH:mm:ss",
            "HH:mm"
        )
        .Select(format => ParseDateTime(Value, format))
        .WhereIsPresent()
        .FindFirst()
        .OrThrow(ex => new RuntimeError($"Cannot convert string ({Value}) to datetime.", ex));
although, these are the pre-defined set of allowed formats that I intend to parse here
 
@Squirrelkiller Fails for "2022-01-19". It requires the trailing time part.
 
@VLAZ Well for "2022-01-19" when it fails, you give back the string as-is and voila, you returned exactly what you wanted: Only the date.
 
Also fails for "2022-01-14T10:00"
 
 
3 hours later…
8:14 PM
 
8:40 PM
David Gibson on January 19, 2022
When the Log4j security issue was disclosed, developers came looking for answers. We took a look at our site data around it.
 
9:35 PM
 
10:18 PM
Hello I have a problem with linq:
` public static bool checkandupdate(IEnumerable<Object> objects, Result result)
{
foreach (var object in objects)
{
var val = object.Values.Select(val =>
{
if (XXX)
{
result.AddError("Error");
return null;
}

return true;
});
object.Values = val;
}
return result.Errors.IsNullOrEmpty();
}`
The result.Errors list is empty and I don't know why
Values contains null elements
 
10:41 PM
hey, I'm still an owner, whee
@Neyoh can you format the code or post a formatted snippet?
 
I can't edit :'( There is the snippet dotnetfiddle.net/ATpz16
 
can you provide a complete example that demonstrates the problem you're experiencing with data that actually runs in dot net fiddle?
remember - you should put in the effort to make it easy for people to answer if you're asking for free help ;)
 
11:00 PM
@Neyoh I'd say none of the values of your objects pass that XXX condition?
 
mr5
11:23 PM
ehhh
o/
\o/
\o
 
11:58 PM
your enumerables arent being evaluated
dont use enumerables as properties, just use the right collections
 

« first day (4113 days earlier)      last day (827 days later) »