also ... @SimonOrro he has used a new Date constructor with a string as an argument, as part of an example. This is something you should not do in production. Either use the other constructor (with numbers) or use a date library if you have to work a lot with it
When using new Date or Date.parse in JavaScript, I cannot just pass arbitrary date formats. Depending on the format, I get a different date than I wanted to or even Invalid Date instead of a date object. Some date formats work in one browser but not in others. So which date time formats should I ...
I'd encourage people to use that for constructing Date objects. It's easier to read and it's officially supported.
Less ambiguous, as well. Erm, unless you compare date strings and datetime strings. Those interpret using different time zones. And don't omit the time zone in a datetime string.
@karan Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
ironically, I'd probably fail to comply if any of my codebases were to be checked - I only recently realised that you can specify type parameters at init time directly like new Map<number, User>, so it's riddled with const umap: Map<number, User> = new Map();
I don't think it's fair to expect your code to comply with any specific coding guideline. It might but parts of the guidelines are opinionated. So, it's hard to match up exactly.
Our codebase fails at the very beginning. Because enums are not named in CAPS_WITH_UNDERSCORES. But that's fine, since they still follow a convention. Erm, well, maybe three different conventions but they follow them.
@VLAZ I actually like Google's coding style and generally follow it to the letter, what I meant is there are still some areas of TS that keep surpizing me (and I claim to have a very good level of understanding of TS) :)
I'm certain their style is sensible. I'm currently looking through it. However, you can have many equally sensible styles which are incompatible, is what I'm saying.
@VLAZ I usually gravitate to the "all caps with underscores" style when naming enum members to have an easy indication that those aren't just interface members but proper enums, but yeah, as long as the naming choice is consistent, it does not really matter
We use SomeNameType for enums in C#. And some of the TS codebase also uses it. Other part of the codebase instead uses SomeNameEnum which I'm iffy on. It does make it clear what it is but I don't like adding the type of the thing in the name of the thing.
@JBis We actually have that. Which alleviates a lot of the work for a styleguide. There is just one point that says "Make sure you use the linter configuration". Instead of having to define the nitty-gritty.
Not sure I'd agree with not using regular functions. I guess they are very rarely needed nowadays but outright banning them doesn't seem correct.
I agree even less with not using arrow function properties. Yes, you probably should avoid it but when you know you have one single instance of a thing (or 2-3) then the extra memory for those function is not an issue. Which you might want if you do class Foo { refresh = debounce(() => /* ... */, 25) } or similar.
@VLAZ eh, that part is opinionated a bit. Generally, I agree with outright banning function - there are extremely few cases where one might want to use it. However, there are, indeed, cases, where one would want function over arrow functions. Great case in point is Mocha where test env overrides only exist as methods on this, so if you want to say "well, this test is going to take longer than usual" in a describe or it block, you will have to use function
Hi, everyone! We've released Chrome Beta 101 (101.0.4951.17) for iOS: it'll become available on App Store in the next few days. You can see a partial list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Harry Souders Google Chrome
@VLAZ yes, the only time I still find "static" classes to be useful is in god-forsaken environments with no proper module system. And even then I usually get a nagging question in my head "why not just use functions?"
@OlegValteriswithUkraine I've said this before (in another room) but static classes are a sign of weakness in OOP. Because it cannot really model an operation not attached to an instance. Which is what a function is. Hence you get that static class. And those exist in Java and C# because both languages just don't have a concept as a top level function.
I feel in TS the "static classes" come from people familiar with languages like Java/C# and thus locked into that paradigm.
reading this article here: yetanothersharepointblog.wordpress.com/2013/07/14/… . This guy is having the same issue as me with user's getting different results due to the time zone. I was reading the answer he found that worked for him, I checked and the regional settings are in UTC. He doesnt really explain what fields he uses or where the self.toUTC (self) came from
@OlegValteriswithUkraine Yes. There are many questions on SO about "how do I do this thing" which hinge on trying to emulate something from another language and searching for the equivalent. Instead of searching for the proper way to do it.
The fromUTC is from sending dates to the SharePoint server, I am guessing VIA a POST? I am not sending any dates like that, I am just reading them to filter certain results
Not only a problem for JS but that's the room we're in.
@BeerusDev Yes, it seems fromUTC is for sending, toUTC is for receiving. The problem seems to be that the dates are just saved (or transmitted?) in a garbage format since they miss the time zone.
Which, you know, is an issue if you want accurate dates.
Well they are stored by locale. So any user in a different time zone reads the result differently. Super annoying, didn't expect to run into this problem until a user from the west coast started experiencing issues with something I built
I took some security at Uni. We were talking about incident response if you are (for some reason) called to examine a PC involved in crime. The first and more crucial thing to do my lecturer said was to take a note of the time on the PC. Since if it's running in a different time zone, you want to be able to adjust the logs later when reading them.
It's not really much different outside of investigating crime.
It is super fucking important to use time zones whenever we deal with time.
2
Recently we had a discussion at work revolving around "good logging practices" and I apparently surprised everybody by reminding them to add the time zone to the logs. Even though we operate on two time zones and we often juggle dates between them. In fact, depending on which log you look at you might see one or the other time zone. And occasionally we have a third one which is UTC.
Trying to figure out if 12:43 is before or after 12:40 where both of these come from different logs is annoying.
The Chrome team is excited to announce the promotion of Chrome 101 to the Beta channel for Windows, Mac and Linux. Chrome 101.0.4951.15 contains our usual under-the-hood performance and stability tweaks, but there are also some cool new features to explore - please head to the Chromium blog to learn more! A full list of changes in this build is available in the log. Interested in switching …
The Dev channel has been updated to 102.0.4972.0 for Windows,Linux and Mac A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Srinivas Sista Google Chrome
Hi everyone! We've just released Chrome Beta 101 (101.0.4951.15) for Android: it's now available on Google Play. You can see a partial list of the changes in the Git log. For details on new features, check out the Chromium blog, and for details on web platform updates, check here. If you find a new issue, please let us know by filing a bug. Erhu Akpobaro Google Chrome
@KevinB Not if it's 12:43+02:00 and 12:40+01:00, for example. Then the second one is after the first one because if you transform them to the same time zone, you get 11:43+01:00 and 12:40+01:00. That's the problem with not knowing which time zone a log is in.
That was my point. The data is that some timestamps are in a different time zone. But without the time zone information, you have to guess. I mean, not too much, but if you only have the logs without their source you don't know exactly which time is in which time zone. And if you're trying to find a problem you want to find the correct timestamp in them.