Representative Line: Tern Down a Date
Today's anonymous submitter has managed to find a way to do date formatting wrong that I don't think I've seen yet. That's always remarkable. Like most such bad code, it checks string lengths and then adds a leading zero, if needed. It's not surprising, but again, it's all in the details:
// convert date string to yyyy/MM/DD return dtmValue.Year + "-" + ((dtmValue.Month.ToString().Length == 1)? ("0" + dtmValue.Month.ToString()): dtmValue.Month.ToString()) + "-" + ((dtmValue.Day.ToString().Length == 1)? ("0" + dtmValue.Day.ToString()): dtmValue.Day.ToString());This is only one line, but it has it all, doesn't it. First, we've got good ol' Hungarian notation, which conveys no useful information here. We've got a comment which tells us the code outputs /es, but the code actually outputs -. We've got ternaries that are definitely not helping readability here, plus repeated calls to ToString() instead of maybe just storing the result in a variable.
And, for the record, dtmValue.ToString("yyyy-MM-dd") would have done the correct thing.
.comment { border: none; }Inside the high-ranking Taliban wedding where the BRIDE was banned from attending
Taylor Swift's friend Jaime King breaks silence after losing custody of kids
Meghan Markle blasted as 'tacky' as discomfort emerges around Duchess 'using hers and Prince Harry's children to promote business ventures' - as she's set to 'make a killing' on Instagram shop
Justin Baldoni doesn't look like this anymore after 'catastrophic' Blake Lively legal woes take their toll
'Counter intuitive' glass tax to cost Essex's Wilkin and Sons £1m in costs annually
'Counter intuitive' glass tax to cost Essex's Wilkin and Sons £1m in costs annually
Witham vet speaks out after helping rescue horse from brook in Holland-on-Sea
Dad 'disgusted' as he claims school failed to spot child's broken ankle in PE
The pretty Essex town with a 'fiercely proud' community named one of the best places to live in the UK
Kanye West flees the US after unhinged rants sparked 'nuclear' war with ex Kim Kardashian
Pennsylvania fire chief admits to throwing his baby daughter on her head and fracturing her skull
Blood-soaked wrestler, 27, electrocutes his own father with jump leads in the ring in 'most gruesome "death match" ever'
Software Maker SAP Becomes Europe's Largest Company
Read more of this story at Slashdot.
Public-facing Kubernetes clusters at risk of takeover thanks to Ingress-Nginx flaw
Cloudy infosec outfit Wiz has discovered serious vulnerabilities in the admission controller component of Ingress-Nginx Controller that could allow the total takeover of Kubernetes clusters – and thinks more than 6,000 deployments of the software are at risk on the internet.…