Note: The code above runs synchronously and blocks your application. To avoid this, you could run it in as a task on the thread pool with Task.Run() or you could use XElement.LoadAsync instead of XElement.Load(), if available.
Suppose you have a document with a date and time column. Calculating time differences is easy, you can simply subtract an earlier time from a later one1. In the screenshot below, column C shows the difference between the time in consecutive rows (column B). However, you can see that this simple approach fails just after midnight:
The time difference in row 4 is negative and also wrong. This becomes very clear when you switch to a 24h time format and enable negative times2:
Solution: Include the date in the calculation
Internally, dates are represented as whole numbers and times as fractional numbers smaller than 1 (1 would be 24h = 1 whole day). This means you can simply add date and time! Therefore, a better formula to calculate time differences is:
By including the date, this formula works fine after midnight.
A3-A2 is the simple time difference calculation we used in the beginning. (A3<A2) returns TRUE only when the next day starts and the time is “smaller” than in the row above (see row 5, column C). What makes this work for our purposes it that TRUE is evaluated as 1 while FALSE is 0 (see column D). As mentioned above, a date/time value of 1 corresponds to 1 day (24h).
In row 5, Excel is therefore calculating the difference between 24h and 23h 59min 59s, which is 1 second.
1 This will work if Excel correctly recognized the value as a time (not a text). You can test this with the ISNUMBER function which should return TRUE. 2 The easiest way to get Excel to show negative times is by enabling the 1904 date system in the advanced options. 3 If you want to see time values of 24h or more, use an elapsed time format with square brackets, e.g. [h]:mm:ss instead of h:mm:ss.
Your company is selling software and a customer in the U.S. is asking you for form W-8BEN-E? You should supply it or risk having 30% of your payment withheld. Some customers might also not place an order at all before receiving this form.
Disclaimer: This blog post is presented for educational and entertainment purposes only. I originally wrote the instructions below for my own company. They might be incomplete, wrong or not applicable to your situation.
What are software licenses (in tax treaty terms)? For this article, I’m assuming they fall under royalties / copyright.
Line 14b: Check the box at the beginning. Will you have to check another box below? The official instructions say:
If you are a resident of a foreign country that has entered into an income tax treaty with the United States that contains a limitation on benefits (LOB) article, you must complete one of the checkboxes in line 14b. You may only check a box if the limitation on benefits article in that treaty includes a provision that corresponds to the checkbox on which you are relying to claim treaty benefits. A particular treaty might not include every type of test for which a checkbox is provided.
Line 15: As far as I understood the instructions, this line has to be filled out only “if the treaty contains different withholding rates for different types of royalties.”[see IRS instructions]. Remember table 1 from the very beginning of this blog post? Look at it again. Are all royalties rates the same? If yes, skip line 15, otherwise, fill it in. As “n/a” is not a rate (I hope), I skipped this line (all rates were the same for Luxembourg).
Part XXX – Certification
Sign, fill in print name and date in U.S. format, check the box at the bottom.
Even though I really don’t want to deal with this topic again, I’ll leave the comments open so that you can correct me on all that’s wrong with my instructions. However, please don’t ask me to help you fill out form W-8BEN-E for your company!
Build a protocol converter. Most scales use proprietary protocols, but you can convert the data to MQTT or other protocols as shown here. Do not say that you have developed a protocol converter, call it an IoT gateway to get more attention.
Use speech synthesis to output the weight as spoken words for visually impaired users.
Use speech recognition to send commands to the scale (e.g. the tare command).
Install a Pi Camera Module and take a picture of the user every time the scale is overloaded.
Turn the scale into a checkweigher by comparing the weight with preset values and making under/accept/over LEDs light up.
Transform the weight into a proportional analog signal (voltage) because… I have no idea! Why do people keep asking for weighing scales with an analog output? Seriously, if you know the answer, please tell me.
Trigger an alarm or something worse when an object is removed from the scale:
Raiders of the Lost Ark IMAX Movie CLIP - Throw Me the Idol (2012) - Harrison Ford Movie