Datum und Zeit zu Word

rage
Benutzer
Avatar
Gender: n/a
Age: 64
Homepage: processanalytik.de
Posts: 235
Registered: 02 / 2007
Subject:

Datum und Zeit zu Word

 · 
Posted: 04.04.2015 - 11:54  ·  #1
Guten Tag

In den Fat16-Libs gibt es ja die Funktionen F16_StrToDate und F16_StrToTime, welches eine korrekten String in ein Word konvertieren. Nun habe ich das Problem, das ich das in einem Projekt brauch, welches keine SD-Karte hat, wo ich also die FAT16 nicht einbinden kann aber trotzdem DateTime in ein Longword konvertieren möchte welches zu den obigen kompatibel ist. Also ein Ersatz für:
Code
Function  DateTimeToLongWord:LongWord;
var wTime,wDate:Word;
    LW:LongWord;
Begin
  wDate :=  F16_StrToDate(SmallDateStr);
  FN    :=  ByteToHex(ClockArray[2])+':'+ByteToHex(ClockArray[1]);
  wTime :=  F16_StrToTime(FN);
  LW    :=  (LongWord(wDate) shl 16) + LongWord(wTime);
  Return(LW);
end;

Hat jemand eine Idee wie sich das bewerkstelligen läßt ohne die FAT16.

Besten Dank und frohe Ostern
rage
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Datum und Zeit zu Word

 · 
Posted: 04.04.2015 - 13:16  ·  #2
Hallo rage,
wenn das weiterhilft:
Code
function F16_DateToStr(FileDate : word) : TF16DateStr;
begin
  DateStr:= byteToStr((byte(FileDate) and $1F) : 2 : '0') + '.';                // day
  DateStr:= DateStr + byteToStr((byte(FileDate shr 5) and $0F) : 2 : '0') + '.';  // month
  DateStr:= DateStr + byteToStr(((hi(FileDate) shr 1) - 20) : 2 : '0');          // year
  return(DateStr);
end;

function F16_TimeToStr(FileTime : word) : TF16TimeStr;
begin
  TimeStr:= byteToStr(hi(FileTime) shr 3 : 2 : '0') + ':';                  // hours
  TimeStr:= TimeStr + byteToStr(byte(FileTime shr 5) and $3F : 2 : '0');    // minutes
  return(TimeStr);
end;

function F16_StrToDate(strDate : TF16DateStr) : word;                  // "dd.mm.yy"
var wDate : Word;
  st             : string[2];
begin
  st:= Copy(strDate, 1, 2);
  wDate:= StrToInt(st) and $1F;
  st:= Copy(strDate, 4, 2);
  wDate:= wDate or (StrToInt(st) and $0F) shl 5;
  st:= Copy(strDate, 7, 2);
  wDate:= wDate or (StrToInt(st) + 20) shl 9;
  return(wDate);
end;

function F16_StrToTime(strTime : TF16TimeStr) : word;                  // "mm:hh"
var wTime : Word;
  st             : string[2];
begin
  st:= Copy(strTime, 1, 2);
  wTime:= (StrToInt(st) and $1F) shl 11;
  st:= Copy(strTime, 4, 2);
  wTime:= wTime or (StrToInt(st) and $3F) shl 5;
  return(wTime);
end;

rolf
rage
Benutzer
Avatar
Gender: n/a
Age: 64
Homepage: processanalytik.de
Posts: 235
Registered: 02 / 2007
Subject:

Re: Datum und Zeit zu Word

 · 
Posted: 04.04.2015 - 13:35  ·  #3
Hallo Herr Hofmann

Perfekt, das hilft.

Besten Dank
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   66   80 · Page-Gen-Time: 0.022493s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI