I've been experiencing a very strange issue in CMD and I can't for the life of me figure out why it's doing this!
I'm performing arithmetic on some dates and subtracting one from the month and it was going just fine until I got to the numbers 8 & 9! Because I'm dealing with dates, I'm adding a preceding 0 for any value less than 10, which makes 8 become 08.
I input the following into the cmd (keep in mind that for values 01, 02, 03, 04, 05, 06, 07 & 10, the below code will work just fine):
set z=08
set /a z-1
somehow this code returns an answer of -1 instead of the expected 7!
yet if I do:
set z=8
set /a z-1
This code returns 7 which is what I would expect.
What on earth is going on here?
Related
I'm trying to parse a string into time with a user-specific timezone location -
// error handling skipped for brevity
loc, _ := time.LoadLocation("Asia/Kolkata")
now, _ := time.ParseInLocation("15:04", "10:10", loc)
fmt.Println("Location : ", loc, " Time : ", now)
The output I get on my system is - Location : Asia/Kolkata Time : 0000-01-01 10:10:00 +0553 HMT
Where did this HMT time zone come from?
If instead of parsing the time I use now := time.Now().In(loc), the timezone printed is correct - IST. Am I doing something wrong with timezone parsng or is my system timezone database faulty?
This may be a relic of the fact that your year for now is 0000, while time.Now() returns the current time. Timezones are weird, and certain locations haven't always used the same timezone. This is an excerpt from the IANA Time Zone Database:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Kolkata 5:53:28 - LMT 1854 Jun 28 # Kolkata
5:53:20 - HMT 1870 # Howrah Mean Time?
5:21:10 - MMT 1906 Jan 1 # Madras local time
5:30 - IST 1941 Oct
5:30 1:00 +0630 1942 May 15
5:30 - IST 1942 Sep
5:30 1:00 +0630 1945 Oct 15
5:30 - IST
If I am interpreting this correctly, it seems HMT was used from 1854 until 1870—I'm not exactly sure why this would cause it to be used for year 0000, which would seem to fall under LMT, but it's possible the Go database is slightly different (or it's possible that I'm misinterpreting the database). If you're concerned about the correct timezone being used for historical dates (like 0000) I'm not sure I can give a great answer, however for anything recent IST should be correctly used.
I am wondering what they formats are? Any advice would be much appreciated. This is used in the IBM application called Tealeaf
4682158116698062848 = 12:00:00 AM
4682162239866667008 = 12:01:00 AM
4682166363035271168 = 12:02:00 AM
4682405506814312448 = 01:00:00 AM
If I have to use an application to convert it, then the choice would be PHP
This looks like a Microsoft OLE Automation timestamp. Here is Microsoft's page about it. It represents the number of 24 hour periods since 1 Jan. 1900.
Looks like 64+ bit stamps. The most significant 28+bits are the seconds about 788 days after some epoch (Jan 1, 1970??) which would make it Feb 28, 1972 - or possible some other encoding based on seconds. The least significant 36-bits are all 0. I would expect the values could reach pow(2,72) or 22 decimal digits.
I am using this format to make my computer speak every hour:
Dim speaks, speech
speaks = “It is ” & hour(time) & ” O’clock”
Set speech = CreateObject(“sapi.spvoice”)
speech.Speak speaks
The problem is it reads it in 24hr and not 12hr format, does anybody happen to know how to fix that? I have my system clock set to 12hr format, but for some reason when its read by Microsoft Hazel, she reads it in 24hr format.
As documented, Hour() returns a number between 0 and 23 representing the current hour. You need to divide the hour modulo 12 to get what you want:
speaks = "It is " & Hour(Time) Mod 12 & " o'clock"
I have a problem with pdf::api2 I need to edit an existing pdf and put in some images. The problem is that for inserting 4 images it takes around 20 seconds per image. So the whole process goes up to minute and a half. Is there some magic i can do to speed up the process? The images are 1920 × 1080 and need to stay that size, because i need quality pdf-s... So without further ado, here is the code:
#!/usr/bin/perl
use PDF::API2;
print "start ".(localtime)."\n";
$pdf = PDF::API2->open("sample.pdf");
$page = $pdf->openpage(1);
$page->mediabox(840,600)
$gfx=$page->gfx;
print "first image ".(localtime)."\n";
$first=$pdf->image_png("first.png");
print "inserting first image ".(localtime)."\n";
$gfx->image($first,134,106,510,281);
print "saving ".(localtime)." \n";
$pdf->saveas('new_file.pdf');
print "done ".(localtime)." \n";
The output i get:
start Mon Jun 3 10:46:31 2013
first image Mon Jun 3 10:46:31 2013
inserting first image Mon Jun 3 10:46:53 2013
saving Mon Jun 3 10:46:53 2013
done Mon Jun 3 10:46:57 2013
So the most time consuming process is image_png which takes 22 seconds in this example... Any help would be appreciated. Thanks
Update: if i use the same image converted to JPEG, it works flawlessly, under a second. The problem is i need the transparency of the PNG files
The documentation for PDF::API2 explicitly says that operations on transparent .png files are slow, and recommends installing PDF::API2::XS or (IIRC) Image::PNG::libpng to speed it up.
I am new to COBOL(and OpenCOBOL) and my question is about "complex-odo" (OCCURS...DEPENDING ON) in OpenCOBOL.
I used 1.0 on following code
......
01 W-PTDO-PROC-TBL.
05 W-PTDO-PROC-ENTRY OCCURS 0 TO 450 TIMES
DEPENDING ON W-PTDO-PROC-MAX
INDEXED BY W-PTDO-PROC-INDX.
10 W-PTDO-PROC-APC PIC X(05).
10 W-PTDO-PROC-LNSUB PIC S9(07) COMP-3.
10 W-PTDO-PROC-KEY.
15 W-PTDO-PROC-WA-OFFSET PIC 9(08)V99.
15 W-PTDO-PROC-UNITS PIC 9(09).
10 W-PTDO-PROC-DEVICE-CNT PIC 9(03).
10 W-PTDO-PROC-DARRAY OCCURS 0 TO 450 TIMES
DEPENDING ON W-PTDO-DARRAY-MAX
INDEXED BY W-PTDO-DARRAY-INDX.
15 W-PTDO-PROC-DHCPCS PIC X(05).
10 W-PTDO-DARRAY-SIZE PIC 9(03).
10 W-PTDO-PROC-TOT-DCHRGS PIC 9(10)V99.
10 W-PTDO-PROC-TOT-DUNITS PIC 9(05).
10 W-PTDO-PROC-USED PIC X(01).
......
and cobc returns with this error msg:
Error: 'W-PTDO-PROC-ENTRY' cannot have the OCCURS clause due to 'W-PTDO-PROC-DARRAY'
And above error msg is issued from field.c where I found this comment
/* the data item that contains a OCCURS DEPENDING clause shall not be subordinate to a data item that has the OCCURS clause */
Is there anyway to make OpenCOBOL support this "complex-odo"?
My above code snippet, with "OCCURS DEPENDING" nested under a higher level "OCCURS" clause, seems to be a well-defined "complex-odo" according to appendix of IBM's COBOL Programming Guide.
Thank you,
Billy Rong
You cannot have a variable length array (OCCURS DEPENDING ON) inside another array!
The processing required is just too complex. If the length of the inner array item was allowed to vary, the only possible way to calculate the start of the Nth entry of the outer array is to sequentially access each inner member from 1 to N and use the DEPENDING ON count to work out its length, and, hence the start of the next array entry.