The recipe id (rid) has to be constructed always in the same way. CookML is using the ID from
Ambrosia since 1997.
The RID contains a random number and a simple hash of the current username (called „Creator ID“) upon creation, which never changes and a date/time value, which can be updated if the recipe is changing. This allows to detect a never version of a recipe during import. The result are two 32 bit values written as „value 1,value 2“ in CookML.
The system user name (login name) is summed up in the following way:
For each character (in upper case): Creator-ID += Ascii(character) * character-position
Character-position is starting at 1
Only the lower 12 bits are used, over runs are ignored.
| |
W |
B |
R |
U |
H |
I |
N |
| ordinal value |
87 |
66 |
82 |
85 |
72 |
73 |
78 |
| * |
| position |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
| = |
| |
87 |
132 |
246 |
340 |
360 |
438 |
546 |
+= 2149 |
Starting with a random number which is increased by 1 (if multiple serial id’s are generated at once), any over runs are ignored.
If an object (recipe) has a valid “RID” one updates only the date portion, the Serial-ID and the Creator-ID will never be changed. This is a change compared to the first version of cookML!
Value 1, Date
| |
3 |
2 |
1 |
0 |
| Bit |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
| |
– |
year – 1980, 11 bits |
month, 4 bits |
days, 5 bits |
hours, 5 bits |
minutes, 6 bits |
| example: 12:09, 16-09-2006 = 27886345 |
| |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
Value 2, Creator ID and Serial ID
| |
3 |
2 |
1 |
0 |
| Bit |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
9 |
8 |
7 |
8 |
5 |
4 |
3 |
2 |
1 |
0 |
| |
Creator ID, 12 bits |
Serial ID, 20 bits |
| Example: Creator ID = 2149, Serial ID = 783150 |
| |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |