Skip to main content

Denmark Tests Unmanned Robotic Sailboat Fleet

1 month 1 week ago
Denmark has deployed four uncrewed robotic sailboats (known as "Voyagers") for a three-month trial to boost maritime surveillance amid rising tensions in the Baltic region. The Associated Press reports: Built by Alameda, California-based company Saildrone, the vessels will patrol Danish and NATO waters in the Baltic and North Seas, where maritime tensions and suspected sabotage have escalated sharply since Russia's full-scale invasion of Ukraine on Feb. 24, 2022. Two of the Voyagers launched Monday from Koge Marina, about 40 kilometers (25 miles) south of the Danish capital, Copenhagen. Powered by wind and solar energy, these sea drones can operate autonomously for months at sea. Saildrone says the vessels carry advanced sensor suites -- radar, infrared and optical cameras, sonar and acoustic monitoring. Their launch comes after two others already joined a NATO patrol on June 6. Saildrone founder and CEO Richard Jenkins compared the vessels to a "truck" that carries sensors and uses machine learning and artificial intelligence to give a "full picture of what's above and below the surface" to about 20 to 30 miles (30 to 50 kilometers) in the open ocean. He said that maritime threats like damage to undersea cables, illegal fishing and the smuggling of people, weapons and drugs are going undetected simply because "no one's observing it." Saildrone, he said, is "going to places ... where we previously didn't have eyes and ears." The Danish Defense Ministry says the trial is aimed at boosting surveillance capacity in under-monitored waters, especially around critical undersea infrastructure such as fiber-optic cables and power lines.

Read more of this story at Slashdot.

BeauHD

CodeSOD: A Second Date

1 month 1 week ago

Ah, bad date handling. We've all seen it. We all know it. So when Lorenzo sent us this C# function, we almost ignored it:

private string GetTimeStamp(DateTime param) { string retDate = param.Year.ToString() + "-"; if (param.Month < 10) retDate = retDate + "0" + param.Month.ToString() + "-"; else retDate = retDate + param.Month.ToString() + "-"; if (param.Day < 10) retDate = retDate + "0" + param.Day.ToString() + " "; else retDate = retDate + param.Day.ToString() + " "; if (param.Hour < 10) retDate = retDate + "0" + param.Hour.ToString() + ":"; else retDate = retDate + param.Hour.ToString() + ":"; if (param.Minute < 10) retDate = retDate + "0" + param.Minute.ToString() + ":"; else retDate = retDate + param.Minute.ToString() + ":"; if (param.Second < 10) retDate = retDate + "0" + param.Second.ToString() + "."; else retDate = retDate + param.Second.ToString() + "."; if (param.Millisecond < 10) retDate = retDate + "0" + param.Millisecond.ToString(); else retDate = retDate + param.Millisecond.ToString(); return retDate; }

Most of this function isn't terribly exciting. We've seen this kind of bad code before, but even when we see a repeat like this, there are still special treats in it. Look at the section for handling milliseconds: if the number is less than 10, they pad it with a leading zero. Just the one, though. One leading zero should be enough for everybody.

But that's not the thing that makes this code special. You see, there's another function worth looking at:

private string FileTimeStamp(DateTime param) { string retDate = param.Year.ToString() + "-"; if (param.Month < 10) retDate = retDate + "0" + param.Month.ToString() + "-"; else retDate = retDate + param.Month.ToString() + "-"; if (param.Day < 10) retDate = retDate + "0" + param.Day.ToString() + " "; else retDate = retDate + param.Day.ToString() + " "; if (param.Hour < 10) retDate = retDate + "0" + param.Hour.ToString() + ":"; else retDate = retDate + param.Hour.ToString() + ":"; if (param.Minute < 10) retDate = retDate + "0" + param.Minute.ToString() + ":"; else retDate = retDate + param.Minute.ToString() + ":"; if (param.Second < 10) retDate = retDate + "0" + param.Second.ToString() + "."; else retDate = retDate + param.Second.ToString() + "."; if (param.Millisecond < 10) retDate = retDate + "0" + param.Millisecond.ToString(); else retDate = retDate + param.Millisecond.ToString(); return retDate; }

Not only did they fail to learn the built-in functions for formatting dates, they forgot about the functions they wrote for formatting dates, and just wrote (or realistically, copy/pasted?) the same function twice.

At least both versions have the same bug with milliseconds. I don't know if I could handle it if they were inconsistent about that.

[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.
Remy Porter