Autor Beitrag
Kri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 118



BeitragVerfasst: Di 15.01.08 15:37 
Hi leute

ich würde gerne einen countdown programmieren, welcher mir anzeigt

1. wieviele sekunden das jahr hat
2. wieviele vergangen sind
3. wieviele noch übrig sind

und mir das ganze in labels und einer progressbar ausgibt.
das ganze sollte natürlich über einen timer aktualisiert werden.
Vielleicht kann mir jemand weiterhelfen.

Grüße
Kri
Mitmischer 1703
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 754
Erhaltene Danke: 19

Win 7, Debian
Delphi Prism, Delphi 7, RAD Studio 2009 Academic, C#, C++, Java, HTML, PHP
BeitragVerfasst: Di 15.01.08 15:53 
das mit den Sekunden im Jahr ist doch realisierbar :roll:!

Das Jahr hat 365*24 Stunden, 365*24*60 Minuten und 365*24*60*60 Sekunden und in einem Schaltjahr 365*24+24 Stunden ...

_________________
Die Lösung ist nicht siebzehn.
Escalade
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 18

Win 95 Only
Pascal only
BeitragVerfasst: Di 15.01.08 16:00 
Titel: Vorschlag
So mein Freund hab für dich nen guten Voschlag
1. 365*24*60.
2. Schau auf das aktuelle Datum und rechne zurück
3. Schau auf das aktuelle Datum und rechne vor

Und Progressbar brauchste net ist eh kagge xD
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Di 15.01.08 16:09 
da gibts auch lustige funktionen in der unit DateUtils. Da kann man so was machen.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Kri Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 118



BeitragVerfasst: Di 15.01.08 20:04 
Ist das so richtig?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
var Date1,Date2,Date3,Datum : TDateTime;
    yyyy1,yyyy2:string;
    yyyy:integer;
begin
  yyyy1:=FormatDateTime('yyyy',Datum);
  yyyy:=StrToInt(yyyy1)+1;
  yyyy2:=IntToStr(yyyy);
  Date1 := StrToDateTime('01.01.'+yyyy1+' 00:00');
  Date2 := Now;
  Date3 := StrToDateTime('01.01.'+yyyy2+' 00:00');
  Label1.Caption:=IntToStr(SecondsBetween(Date1, Date2));
  Label2.Caption:=IntToStr(SecondsBetween(Date2, Date3));
end;


EDIT: ganz oben muss noch Datum:=Now; hin.

Grüße
Kri
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Di 15.01.08 20:18 
Sollte funktionieren.
icho2099
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 101
Erhaltene Danke: 12

WIN XP, WIN 7, WIN 10
Delphi 6 Prof, Delphi 2005, FPC
BeitragVerfasst: So 20.01.08 17:04 
Titel: oder so
so gehts auch


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,
  DateUtils;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    LBL1: TLabel;
    LBL2: TLabel;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
Var sec1, sec2   : Double;
begin
  sec1 := SecondsBetween(StartOfTheYear(Now),Now);
  sec2 := SecondsBetween(Now,EndOfTheYear(Now));
  LBL1.Caption := 'Sekunden seit Jahresanfang : ' + Format('%12.0n',[sec1]);
  LBL2.Caption := 'Sekunden bis Jahresende : ' + Format('%12.0n',[sec2]);
end;

end.