|
|
|
รบกวนขอโค๊ด หรือวิธี แปลงวันที่ จากวันที่สากล เป็นวันที่แบบไทยครับ |
|
|
|
|
|
|
|
คงจะต้องเขียน function ขึ้นมาเองแล้วครับ
|
|
|
|
|
Date :
2010-08-10 21:19:08 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หุหุ ยากครับงานนนี้ ขอยกเว้นมันเยอะมาก
|
|
|
|
|
Date :
2010-08-10 21:46:08 |
By :
tungman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำปฏิทินไทยหรอคะ อยากทำเหมือนกัน เคยพยายามแกะอัลกอลมาทีนึงแต่งานเข้าก่อนเลยค้างๆคาๆค่ะ
เรื่องว่าจะทำปฏิทินข้างขึ้นข้างแรมน่าจะทำได้ แต่จะทำปฏิทินวันพระคงยากหน่อยค่ะ
เพราะวันพระบางวันบางส่วนยังต้องพึ่งมติของโหรค่ะ
วันพระ-วันเพ็ญ ข้างขึ้น-ข้างแรม และปฏิทินไทย
ปฏิทินไทย
แล้วก้อมีคำทำเครื่องคำนวนด้วย microcontroller มาด้วยนุ หุย มีให้โหลดทั้ง pcb แล้วก้อ firmware ค่ะ
LunarCalc : เครื่องคำนวนดวงจันทร์ พินิจจันทร์
^^ ถ้าแกะได้รบกวนเผยแพร่ด้วยนะคะ
|
ประวัติการแก้ไข 2010-08-12 06:00:25 2010-08-12 06:17:37
|
|
|
|
Date :
2010-08-12 05:59:30 |
By :
blurEyes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ความตายไม่อาจพลัดพราก ความรู้จากเราไปได้
|
|
|
|
|
Date :
2010-08-13 18:34:25 |
By :
BABA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มีคัย ทำได้หรือยังครับ
|
|
|
|
|
Date :
2015-09-29 02:36:38 |
By :
ktppro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี library หรือแนวทางไหมครับ ผมต้องทำแอพลง
Android
|
|
|
|
|
Date :
2023-12-30 13:07:59 |
By :
. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มีแต่เป็น pascal ต้องเอาไปแปลงเอง นะครับ
ปล. เพิ่งขุดเจอ 55555
constant บางตัวก็ไม่ได้ใช้ ก็พิจารณาดูจะลบมันยังเอาเองนะครับ
Code
unit UConst;
interface
uses SysUtils, classes, UITypes, FMX.Types;
const
domain: string = 'https://uranian-astrology.com//';
ajax: string = 'https://uranian-astrology.com/Ajax/';
//domain: string = 'http://astro.thaigamehub.com/';
//ajax: string = 'http://astro.thaigamehub.com/Ajax/';
Letter_a: string = 'กขคฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวษศสหฬอฮ';
Letter_b: string = 'ะาิีึืุูเแำไใโ';
Letter_c: string = '่้๊๋็์ั';
Set_latitude: double = 13.778;
Set_longitude: double = 100.567;
Kong_latitude: double = 13.778;
Kong_longitude: double = 105.54;
nmTongChai: integer = 1; nmAtibodi: integer = 2; nmUbat: integer = 3; nmLoga: integer = 4;
cfg_yams: array[1..9,0..1] of integer = (
(3,26),(4,56),(7,33),(5,36),(8,40),(6,70),(1,20),(2,50),(9,34)
);
WeekNames: array[0..2,1..7] of string = (
('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'),
('อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'),
('อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสฯ', 'ศุกร์', 'เสาร์')
);
NakSadName: Array[0..1,1..12] of string = (
('chuad','charu','kal','toa','malong','maseng','mamia','mamae','wog','raga','jo','guun'),
( 'ชวด', 'ฉลู', 'ขาล' ,'เถาะ' , 'มะโรง', 'มะเส็ง',
'มะเมีย', 'มะแม', 'วอก', 'ระกา', 'จอ', 'กุน')
);
ZodiacTh: array [0 .. 11] of string = (
'มังกร', 'กุมภ์', 'มีน','เมษ', 'พฤษภ', 'เมถุน', 'กรกฏ',
'สิงห์', 'กันย์', 'ตุลย์', 'พิจิก', 'ธนู');
ZodiacEn: array [0 .. 11] of string = (
'Cap','Aqu','Pis','Ari','Tau','Gem', 'Can','Leo','Vir','Lib','Sco','Sag');
DayTh: array [0 .. 6] of String = ('จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี',
'ศุกร์', 'เสาร์', 'อาทิตย์');
DayEn: array [0 .. 6] of String = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
KhongJiemLong = 105;
NoSelect: string = 'ยังไม่ได้กำหนด';
gsize:single = 1000;
gcenter: integer = 500;
starsize: single = 10;
HexMap: UTF8String = '0123456789ABCDEF';
//Font_Size: integer = 16;
//BorderNone: string = 'pnRightStyle1';
alFit: TAlignLayout = TAlignLayout.Fit;
alNone: TAlignLayout = TAlignLayout.None;
alLeft: TAlignLayout = TAlignLayout.Left;
alRight: TAlignLayout = TAlignLayout.Right;
alTop: TAlignLayout = TAlignLayout.Top;
alBottom: TAlignLayout = TAlignLayout.Bottom;
alCenter: TAlignLayout = TAlignLayout.Center;
alClient: TAlignLayout = TAlignLayout.Client;
taLeft: TTextAlign = TTextAlign.Leading;
taRight: TTextAlign = TTextAlign.Trailing;
taCenter: TTextAlign = TTextAlign.Center;
clWhite: TAlphaColor = TAlphaColors.White;
clBlack: TAlphaColor = TAlphaColors.Black;
clBlue: TAlphaColor = TAlphaColors.Blue;
clRed: TAlphaColor = TAlphaColors.Red;
clYellow: TAlphaColor = TAlphaColors.Yellow;
clBrown: TAlphaColor = TAlphaColors.Brown;
clGreen: TAlphaColor = TAlphaColors.Green;
clGray: TAlphaColor = TAlphaColors.Gray;
clGold: TAlphaColor = TAlphaColors.Gold;
clAqua: TAlphaColor = TAlphaColors.Aqua;
clDarkblue: TAlphaColor = TAlphaColors.Darkblue;
clDarkgreen: TAlphaColor = TAlphaColors.Darkgreen;
clDarkcyan: TAlphaColor = TAlphaColors.Darkcyan;
clDarkgoldenrod: TAlphaColor = TAlphaColors.Darkgoldenrod;
Type
TMyEvent = procedure(Sender: TObject) of object;
TxChange = procedure(Const Value: Integer) of object;
function Iff(const Condition: Boolean; const T,F: string ): string; overload;
function Iff(const Condition: Boolean; const T,F: Char ): Char; overload;
function Iff(const Condition: Boolean; const T,F: Byte ): Byte; overload;
function Iff(const Condition: Boolean; const T,F: Integer ): Integer; overload;
function Iff(const Condition: Boolean; const T,F: Cardinal): Cardinal; overload;
function Iff(const Condition: Boolean; const T,F: Double ): Double; overload;
function Iff(const Condition: Boolean; const T,F: Pointer ): Pointer; overload;
function Iff(const Condition: Boolean; const T,F: Int64 ): Int64; overload;
function Iff(const Condition: Boolean; const T,F: Variant ): Variant; overload;
function Iff(const Condition,T,F: Boolean ): Boolean; overload;
function x360(Const p: single): single;
implementation
//-------------------------------------------------------------------
function x360(Const p: single): Single;
var t: single;
begin t:=p;
if t<0
then begin while t<0 do t:=t+360; end
else begin while t>360 do t:=t-360; end;
result:=t;
end;
//-------------------------------------------------------------------
function Iff(const Condition: Boolean; const T, F: Integer): Integer;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Cardinal): Cardinal;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Byte): Byte;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: string): string;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Char): Char;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Int64): Int64;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Variant): Variant;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Pointer): Pointer;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition: Boolean; const T, F: Double): Double;
begin if Condition then Result:=T else Result:=F; end;
function Iff(const Condition, T, F: Boolean): Boolean;
begin if Condition then Result:=T else Result:=F; end;
end.
Code
unit UMoon;
interface
uses
SysUtils, StrUtils, Classes, UITypes, Types, DateUtils, INIFiles,
FMX.Graphics, FMX.Controls, FMX.Dialogs, Math, FMX.Types,
FMX.StdCtrls, FMX.ExtCtrls, RegularExpressions;
type
TRuekYams = record
van: word;
yam: word;
rasi: word;
diti: word;
RuekBon: word;
RuekLang: word;
End;
TRasi = class(Tobject)
Constructor Create;
private
y: integer;
m: integer;
d: integer;
w: integer;
function gThMoonStat: string;
function gNakSat(typ: byte): string;
public
m82: boolean;
function Year: integer; // 1-12
property Naksat[typ: byte]: string read gNaksat;
function Month: integer; // 1-12
property Week: integer read w write w; // 1-7
function Moon: integer; // 1-15
property ThMoonStat: string read gThMoonStat;
function isRam: Boolean; // + or -
function Text: string; // Wan Atid up 1 kam duen 1 Year chuad
procedure EngDate(Date: TDateTime);
function isAtigavarn(y: word): boolean;
function isAtigamas(const y: word): boolean;
end;
TRuekYam = class(Tobject)
constructor create;
public
ry: array[1..4] of TRuekYams;
curdate: TDateTime;
curweek: integer;
function futday(const tarW: integer): integer;
procedure getVan( var ton, atb, uba, log: integer);
procedure getDiti( var ton, atb, uba, log: integer);
procedure getXyam( const idx, val: integer; var yam, m0, m1: integer);
function isAtigavarn(y: word): boolean;
function isAtigamas(const y: word): boolean;
procedure setRuek(var r: TRuekYams; const y: word);
procedure setDate(const dte: TDateTime);
End;
TMoonAlab = class(Tobject)
id, typ: integer;
Roman: string;
Start, Center, Last: single;
constructor Create(_id: integer; _rom: string; Wd, St: single); overload;
constructor Create(_id: integer; _rom: string; a,d,l: Integer); overload;
function Text: string;
function Strings: String;
function width: integer;
procedure SetStart(Prev: single);
procedure SetLast(Next: single);
end;
implementation
uses UConst;
{ TRuekYam }
constructor TRuekYam.create;
begin
//
end;
function TRuekYam.futday(const tarW: integer): integer;
var cur, tar: integer;
begin
tar:=tarW; cur:=curweek mod 7;
if cur>tar then inc(tar, 7);
futday:=tar-cur;
end;
procedure TRuekYam.getVan(var ton, atb, uba, log: integer);
begin
ton:=futday(ry[nmTongChai].van);
atb:=futday(ry[nmAtibodi].van);
uba:=futday(ry[nmUbat].van);
log:=futday(ry[nmLoga].van);
end;
procedure TRuekYam.getDiti(var ton, atb, uba, log: integer);
begin
//getCurDiti();
ton:=ry[nmTongChai].diti;
atb:=ry[nmAtibodi].diti;
uba:=ry[nmUbat].diti;
log:=ry[nmLoga].diti;
end;
procedure TRuekYam.getXyam(const idx, val: integer; var yam, m0, m1: integer);
var chk: boolean;
begin
yam:=1; m0:=val; chk:=False;
repeat
if cfg_yams[yam,0]=idx then chk:=True
else begin inc(yam); if yam=9 then yam:=1; end;
until chk;
WriteLn( yam, ':', val );
while m0>cfg_yams[yam,1] do
begin
dec(m0, cfg_yams[yam,1]);
inc(yam); if yam>9 then yam:=1;
end;
if m0=cfg_yams[yam,1] then m0 := 0;// else m0 := cfg_yams[yam,1] - m0;
m1 := cfg_yams[yam,1];
end;
function TRuekYam.isAtigamas(const y: word): boolean;
begin
case ( y + 543) of
2450,2452,2455,2458,2461,2463,2466,2469,2471,2474,2477,
2480,2482,2485,2487,2490,2493,2496,2499,2501,2504,2507,
2509,2512,2515,2518,2520,2523,2526,2528,2531,2534,2536,
2539,2542,2545,2547,2550,2553,2555,2558,2561,2564,2566,
2569,2572,2574,2577,2580,2583: result:=true;
else result:=false;
end;
end;
function TRuekYam.isAtigavarn(y: word): boolean;
begin
case (y+543) of
2451,2457,2460,2468,2472,2476,2479,2488,2492,2495,
2500,2506,2513,2516,2522,2530,2533,2540,2543,2549,
2552,2559,2567,2568,2575,2578,2584: result:=true;
else result:=false;
end;
end;
procedure TRuekYam.setDate(const dte: TDateTime);
var yy, Y, M, D: word;
begin
curdate:=dte;
curweek:=DayOfWeek(curdate);
decodedate(dte, Y, M, D); yy := y - 638;
setRuek( ry[nmTongChai], yy * 10 + 3);
setRuek( ry[nmAtibodi], yy mod 498);
setRuek( ry[nmUbat], yy * 10 +2);
setRuek( ry[nmLoga], YY + 1120);
end;
procedure TRuekYam.setRuek(var r: TRuekYams; const y: word);
begin
r.van:=y mod 7;
r.yam:=y mod 8;
r.rasi:=y mod 12;
r.diti:=(y-1) mod 30;
r.RuekBon:=y mod 27;
r.RuekLang:=y mod 9;
end;
{ TRasi }
function TRasi.Year: integer; // 1-12
begin
Year:=y;
end;
//
function TRasi.gNaksat(typ: byte): string;
begin
result:=NakSadName[typ, y];
end;
//
function TRasi.Month: integer; // 1-12
begin
Month:=m+1;
end;
//
function TRasi.Moon: integer; // 1-15
begin
Moon:=(d mod 15) + 1;
end;
//
function TRasi.gThMoonStat: string;
begin result:=iff(isRam, 'แรม', 'ค่ำ'); end;
function TRasi.isAtigamas(const y: word): boolean;
begin
case ( y + 543) of
2450,2452,2455,2458,2461,2463,2466,2469,2471,2474,2477,
2480,2482,2485,2487,2490,2493,2496,2499,2501,2504,2507,
2509,2512,2515,2518,2520,2523,2526,2528,2531,2534,2536,
2539,2542,2545,2547,2550,2553,2555,2558,2561,2564,2566,
2569,2572,2574,2577,2580,2583: result:=true;
else result:=false;
end;
end;
function TRasi.isAtigavarn(y: word): boolean;
begin
case (y+543) of
2451,2457,2460,2468,2472,2476,2479,2488,2492,2495,
2500,2506,2513,2516,2522,2530,2533,2540,2543,2549,
2552,2559,2567,2568,2575,2578,2584: result:=true;
else result:=false;
end;
end;
function TRasi.isRam: Boolean; // + or -
begin result:=d>14; end;
//
function TRasi.Text: string; // Wan Atid up 1 kam duen 1 Year chuad
begin
Text:=
'วัน' + WeekNames[2,w] +
' ' + iff(isRam,'แรม','ขึ้น') +' ' + inttostr(Moon) + ' ค่ำ' +
' เดือน '+ inttostr(m+1) +
' ปี' + NaksadName[1,y];
end;
constructor TRasi.Create;
begin
EngDate(now);
end;
procedure TRasi.EngDate(Date: TDateTime);
var
s, next: TDateTime;
day: integer;
c_y, c_m, c_d, b_y, b_m, b_d: word;
begin
s:=encodedate(1907,12,05);
m:=0; m82:=false;
while s < Date do
begin
decodedate( s, c_y, c_m, c_d);
day:=30; if( (m mod 2)=0 ) then day:=29;
if (m=6) AND isAtigavarn(c_y) then Inc(day);
next:=IncDay( s, day);
if next>Date then break;
s:=next;
if(m=7) and isAtigamas(c_y) and (m82=false)
then m82:=true
else
begin
m82:=false; m:=(m+1) mod 12;
end;
end;
decodedate( Date, b_y, b_m, b_d);
w:=DayOfWeek(Date);
d:= DaysBetween(Date , s); // 0-29
y:=((b_y - 4) mod 12) + 1;
end;
{ TMoonAlab }
constructor TMoonAlab.Create(_id: integer; _rom: string; wd, st: single);
begin
id:=_id; Roman:=_rom; Start:=st; Last:=st + wd;
Center:=st + (wd / 2); Typ:=0;
end;
constructor TMoonAlab.Create(_id: integer; _rom: string; a, d, l: Integer);
begin
id:=_id; Roman:=_rom; Center:=a * 30 + d + (l/60); Typ:=1;
end;
procedure TMoonAlab.SetLast(Next: single);
var d: single;
begin
d:=center + Next;
if Center>Next then d:=d + 360; Last:=d / 2;
if Last>360 then Last:= Last - 360;
end;
procedure TMoonAlab.SetStart(Prev: single);
var d: single;
begin
d:=center + Prev;
if Prev > Center then d:=d + 360; Start:=d / 2;
if start>360 then start:= start - 360;
end;
function TMoonAlab.Strings: String;
begin
result:=IntToStr(id)
+ chr(13) + FormatFloat(' 000.00',Width)
+ chr(13) + FormatFloat(' 000.00',Start)
+ chr(13) + FormatFloat(' 000.00',Last);
end;
function TMoonAlab.Text: string;
begin
result:=IntToStr(id)
+ FormatFloat(' 000.00',Width)
+ FormatFloat(' 000.00',Start)
+ FormatFloat(' 000.00',Last);
end;
function TMoonAlab.width: integer;
begin
if Start>Last
then result:=floor(Last + 360 - Start)
else result:=floor(Last - Start);
end;
end.
|
ประวัติการแก้ไข 2024-01-05 11:54:13
|
|
|
|
Date :
2024-01-05 11:38:57 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|