[Info-vax] VMS Software Bootcamp 2024

Arne Vajhøj arne at vajhoej.dk
Tue Sep 17 20:37:37 EDT 2024


On 9/17/2024 7:06 PM, Arne Vajhøj wrote:
> On 9/17/2024 3:42 PM, Tom Wade wrote:
>>> I must admit I was a bit surprised to see it written in the way it was
>>> as I am much more used to a 24-hour clock. I don't know if that's more
>>> of a European thing than a US thing however.
>>
>> I was quite disappointed to see it written that way.  VMS has always 
>> used 24 hour time, and the traditional DECUS US agendas were also 
>> listed that way, with sessions starting at 08:00 and some days ending 
>> at 23:00.
> 
> The traditional VMS time text format is pretty good. Very difficult
> to misunderstand.
> 
> Of course in most programming languages today you can specify
> the format to use.
> 
> $ show time
>    17-SEP-2024 19:03:14
> $ type now.groovy
> import java.text.*
> 
> df1 = new SimpleDateFormat("HH:mm")
> df2 = new SimpleDateFormat("hh:mm a")
> 
> now = new Date()
> println(df1.format(now))
> println(df2.format(now))
> $ groovy now.groovy
> 19:03
> 07:03 PM
> $ type now.py
> from time import *
> 
> now = time()
> print(strftime('%H:%M', localtime(now)))
> print(strftime('%I:%M %p', localtime(now)))
> $ python now.py
> 19:03
> 07:03 PM

The Bazaar philosophy of PHP is very obvious for this topic:

$ type now.php
<?php

date_default_timezone_set('EST');
$now = time();

// old style
echo sprintf("%s\r\n", date('H:i', $now));
echo sprintf("%s\r\n", date('h:i A', $now));

// C style
echo sprintf("%s\r\n", strftime('%H:%M', $now));
echo sprintf("%s\r\n", strftime('%I:%M %p', $now));

// new style
$dt = new DateTime();
$dt->setTimestamp($now);
echo sprintf("%s\r\n", $dt->format('H:i'));
echo sprintf("%s\r\n", $dt->format('h:i A'));

// ICU style (requires intl extension loaded)
if(extension_loaded('intl')) {
     $fmt1 = new IntlDateFormatter('EN-us');
     $fmt1->setPattern('HH:mm');
     $fmt2 = new IntlDateFormatter('EN-us');
     $fmt2->setPattern('hh:mm a');
     echo sprintf("%s\r\n", $fmt1->format($now));
     echo sprintf("%s\r\n", $fmt2->format($now));
}

?>
$ php now.php
20:32
08:32 PM
20:32
08:32 PM
20:32
08:32 PM

(Berryman PHP apparently does not come with INTL extension)

Arne




More information about the Info-vax mailing list