Hex time format - time

I have a few hexadecimal values which contain time data. I've tried to figure out the format using different conversions (seconds, minutes, bitshifts and so on) but without success. How do I convert those hex values to hours and minutes?
HH:MM HEX DEC
00:03 = 006A = 106
08:44 = 4185 = 16773
11:00 = 5285 = 21125
12:23 = 5CE5 = 23781
12:29 = 5DA5 = 23973
13:13 = 6325 = 25381
14:04 = 6985 = 27013
15:40 = 7585 = 30085
16:31 = 7BE5 = 31717
18:23 = 89E5 = 35301
18:42 = 8C43 = 35907
18:51 = 8D65 = 36197
19:20 = 9105 = 37125
19:25 = 91A5 = 37285
19:36 = 930B = 37643
23:36 = B105 = 45317
23:39 = B165 = 45413

It would seem that if you shift the values right by 5 bits you get a time value in minutes.
The bottom bits seem to vary. I'm not sure what they mean.

Related

Why is Lua's table.sort method not working on my data

I'm trying to do a seemingly very simple sort process on an array-type table of data.
This is my sort function:
function ArraySort(t)
local sorted = {}
for i in ipairs(t) do table.insert(sorted,t[i]) end
table.sort(sorted)
return sorted
end
Here's what the original data looks like:
T:------[presets unsorted]-----
1 = Showdown
2 = Kora
3 = Marxophone
4 = Mountain Home
5 = Soft Koto
6 = ElectroClav
7 = Bad Actor
8 = Glass Harp
9 = Panorama
10 = Winwood
11 = ElectroTuba
12 = alto flute
13 = Clear Bell
14 = Third Man
15 = Wooden Bars
16 = Silver Bowl
17 = Rayong
18 = frippery
19 = red cedar
20 = theater flutes
21 = lowrey
22 = theater flutes 2
23 = Steel String
24 = quiet place
25 = treadwell pad
26 = alpen drive
27 = Bassonery
28 = Clarinets
29 = Silent Movie
30 = Hudi-gurdi
31 = Silent Screen
32 = Light Bulb
33 = Zithar Pad
34 = Oboid Jazz
35 = Quacking
36 = More Quacking
37 = Horn Ensemble
38 = Knell
39 = steampipe
40 = Saturated Ping
41 = fuzz floot
42 = Thin Pad
43 = SheenPad
44 = flutar
45 = Acoustic Bass
46 = new whirled
47 = heavy breathing
48 = whisper cycle
49 = 2nd Harmonium
50 = Tubular Bells
51 = Fat Clav
52 = Obese Clav
53 = clank
54 = ghost flute
55 = alto flute
56 = ghost Train
57 = Clear Bell
58 = Talkbox Bass
59 = Zenith
60 = Chirp Synth
61 = ElectroTuba
62 = ElectroClav
63 = Silver Screen
0 = Lead Bass
---------------------------
Here's what my sort method returns:
T:------[sorted presets]-----
1 = 2nd Harmonium
2 = Acoustic Bass
3 = Bad Actor
4 = Bassonery
5 = Chirp Synth
6 = Clarinets
7 = Clear Bell
8 = Clear Bell
9 = ElectroClav
10 = ElectroClav
11 = ElectroTuba
12 = ElectroTuba
13 = Fat Clav
14 = Glass Harp
15 = Horn Ensemble
16 = Hudi-gurdi
17 = Knell
18 = Kora
19 = Light Bulb
20 = Marxophone
21 = More Quacking
22 = Mountain Home
23 = Obese Clav
24 = Oboid Jazz
25 = Panorama
26 = Quacking
27 = Rayong
28 = Saturated Ping
29 = SheenPad
30 = Showdown
31 = Silent Movie
32 = Silent Screen
33 = Silver Bowl
34 = Silver Screen
35 = Soft Koto
36 = Steel String
37 = Talkbox Bass
38 = Thin Pad
39 = Third Man
40 = Tubular Bells
41 = Winwood
42 = Wooden Bars
43 = Zenith
44 = Zithar Pad
45 = alpen drive
46 = alto flute
47 = alto flute
48 = clank
49 = flutar
50 = frippery
51 = fuzz floot
52 = ghost Train
53 = ghost flute
54 = heavy breathing
55 = lowrey
56 = new whirled
57 = quiet place
58 = red cedar
59 = steampipe
60 = theater flutes
61 = theater flutes 2
62 = treadwell pad
63 = whisper cycle
-----------------------------
I can't figure out why it's sorting into two groups.... it doesn't strike me as the kind of data that would require a special sort method... but this doesn't seem like that kind of problem anyway.
There are no surprises: in ASCII and UTF-8, uppercase letters come before lowercase letters.
To ignore case when sorting, use
table.sort(sorted, function (a,b) return a:lower()< b:lower() end)

Dynamically adjusting number in Ruby

I maintain an in stock count in our application but each day I want to overwrite that number with the in stock count on the stock list that comes from our supplier.
The problem that I have is that the application that I use requires an adjustment rather than just setting what the new in stock count should be.
my_available = 10
supplier_available = 0
adjustment = -10
my_available = 0
supplier_available = 10
adjustment = +10
my_available = -10
supplier_available = 0
adjustment = +10
How can I calculate the adjustment in Ruby?
try: adjustment = supplier_available - my_available
This will yield the correct result for the samples you gave:
my_available = 10
supplier_available = 0
adjustment = -10 # => 0 - 10
my_available = 0
supplier_available = 10
adjustment = +10 # => 10 - 0
my_available = -10
supplier_available = 0
adjustment = +10 # => 0 - -10
Note that +10 and 10 is the same (+10 == 10 => true) so you can drop the sign for positive numbers.
not sure if I clearly understand the question but have you tried something like the example below?
my_available = -10
supplier_available = 0
a = supplier_available - my_available
adjustment = if a>0
a = '+'+a
else
a
end

Base64 encode characters in java, how to do in java

I want to create this string on base of the current time.
For example:
2014 06 04 16 21 20 79 ---> 14 06 04 16 21 20 79
Then I can translate every two digits (except last two) for an alphanumeric character using table ( http://en.wikipedia.org/wiki/Base64 - note that all of them are smaller than 59)
then
14 - O
06 - G
04 - E
16 - Q
21 - V
20 - U
SimpleDateFormat formatter = new SimpleDateFormat("MM.dd.HH.mm.ss");
String timeStamp = formatter.format(new java.util.Date());
String[] data = timeStamp.split(".", 5);
String abc = new String();
for (int j = 0; j < 5; j++) {
abc = abc.concat(StringUtils.newStringUtf8(Base64.decodeBase64(data[j])));
}

For Loop SSIS - AssignExpression

I am newbie to SSIS so please bear with me if this question is super easy to you.
I am using a for loop container and the condition are based on variables (in the format of YYYMM), in the AssignExpression I am increment the variable by 1 which gives the next month.
How do i achieve the same functionality for year ending months?
For Example StartValue 198906:
AssignExpression (#StartValue = #StartValue + 1), so this gives me 198907, but how how i get to 198912 to 198301
Thanks,
You can use a function like the one below in the script task:
Function fctStartMonth (pStartMonth as String, pCounter as Integer) as String
Dim intMonth as Integer
Dim intYear as Integer
intMonth = CInt(Right(pStartMonth,2))+ pCounter -1
intYear = CInt(Left(pStartMonth,4))
if intMonth > 12 then
intYear = intYear + 1
if intMonth = 13 then intMonth = 1
if intMonth = 14 then intMonth = 2
if intMonth = 15 then intMonth = 3
if intMonth = 16 then intMonth = 4
if intMonth = 17 then intMonth = 5
if intMonth = 18 then intMonth = 6
if intMonth = 19 then intMonth = 7
if intMonth = 20 then intMonth = 8
if intMonth = 21 then intMonth = 9
if intMonth = 22 then intMonth = 10
if intMonth = 23 then intMonth = 11
if intMonth = 23 then intMonth = 12
End If
fctStartMonth = CStr(intYear) & "-" & Right("0" & CStr(intMonth),2)
End Function
You could use this as your assign expression:
#StartValue = (DT_I4)RIGHT((DT_STR, 6, 1252)#StartValue,2) - 12 == 0 ? #StartValue +89 : #StartValue + 1
I would suggest to first parse a date from your initial value, such as
(DT_DATE)(LEFT("201601",4)+"-"+RIGHT("201601",2)+"-"+"01")
Afterwards you can loop over it and use
DATEADD( "mm", 1, #YourDate)
in order to increase the value. This will handle the year change for you.

Information on Hook Constants

Anyone can explain what these hooks do? Especially WH_MIN and WH_MAX.
http://msdn.microsoft.com/en-us/library/ms644959(VS.85).aspx
WH_MIN = -1
WH_MSGFILTER = -1
WH_JOURNALRECORD = 0
WH_JOURNALPLAYBACK = 1
WH_KEYBOARD = 2
WH_GETMESSAGE = 3
WH_CALLWNDPROC = 4
WH_CBT = 5
WH_SYSMSGFILTER = 6
WH_MOUSE = 7
WH_HARDWARE = 8
WH_DEBUG = 9
WH_SHELL = 10
WH_FOREGROUNDIDLE = 11
WH_CALLWNDPROCRET = 12
WH_KEYBOARD_LL = 13
WH_MOUSE_LL = 14
WH_MAX = 15
MIN and MAX values like that are usually just there so you know the range of valid numbers

Resources