About datetime format for Listview

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

About datetime format for Listview

15 Aug 2018, 05:16

I'm having trouble using datetime when I work.

I want the format of the date entered in datetime to be dd/MM/yyyy. I could not find where I was making mistakes.
I want the date format to be in dd/mm/yyyy format when I add, edit and save to the ini file with the gui menun installation.
Can you help me please..



Code: Select all

#SingleInstance force
#NoEnv
SetBatchLines -1
;~ Gui, Submit, NoHide
bertarafs:="AKRE GERİ DÖNÜŞÜM LİMİTED ŞİRKETİ|DURMAZ MOTORLU ARAÇLAR OTOMOTİV SERVİS YEDEK PARÇA GERİ KAZANIM  DÖNÜŞÜM SANAYİ VE TİCARET LİMİTED ŞİRKETİ"

f = ArtesYedek.ini
IfNotExist, %f%

{ ;Sample data
 IniWrite,  1 , %f%, Count, ID#
 IniWrite, |1|, %f%, Count, list
 IniWrite, EI893726*42NU447*6230090752 , %f%, 1, BARKOD
 IniWrite, 34ABC23 , %f%, 1, Plaka Numarası
 IniWrite, AB123456 , %f%, 1, Belge Seri Numarası
 IniWrite, 22033921350 , %f%, 1, T.C. Kimlik/Vergi Numarası
 IniWrite, 33613398264 , %f%, 1, Vekil T.C./Vergi Numarası
 IniWrite, BAKIRKÖY 24 , %f%, 1, Noterlik Adı
 IniWrite, 12345 , %f%, 1, Yevmiye No
 IniWrite, 01/01/2018 , %f%, 1, Yevmiye Tarihi
 IniWrite, AKRE GERİ DÖNÜŞÜM LİMİTED ŞİRKETİ , %f%, 1, Bertaraf Şirketi
 IniWrite, 000034 , %f%, 1,  Bertaraf Şirketi Kodu
 IniWrite, 01/01/2018 , %f%, 1, Bertaraf Rapor tarihi
}


Gui, Add, Text, x12 y10 w180 h17 , BARKOD
Gui, Add, Edit, x12 y25 w180 h20 vBARKOD gBarkodOkut, ED123456*34ABC123*33613344264 
Gui, Add, Text, x202 y10 w130 h17 , Plaka Numarası
Gui, Add, Edit, x202 y25 w130 h20 vPlakaNo, 
Gui, Add, Text, x342 y10 w130 h17 , Belge Seri Numarası
Gui, Add, Edit, x342 y25 w130 h20 vBelgeNo,
Gui, Add, Text, x482 y10 w130 h17 , T.C. Kimlik/Vergi Numarası
Gui, Add, Edit, x482 y25 w130 h20 vTCVergiNo,


Gui, Add, Text, x12 y50 w180 h17 , Vekil T.C./Vergi Numarası
Gui, Add, Edit, x12 y65 w180 h20 vVekilTCVergiNo, 22033921350

Gui, Add, Text, x202 y50 w130 h17 , Noterlik Adı
Gui, Add, Edit, x202 y65 w130 h20 vNoterlikAdi ,
Gui, Add, Text, x342 y50 w130 h17, Yevmiye No
Gui, Add, Edit, x342 y65 w130 h20 vYevmiyeNo,

Gui, Add, Text, x482 y50 w130 h17 , Yevmiye Tarihi
Gui, Add, DateTime,  x482 y65 w130 h20 vYevmiyeTarihi gtarih Section

Gui, Add, Text, x482 y90 w130 h17 , Bertaraf Rapor Tarihi
Gui, Add, DateTime, x482 y105 w130 h20 vBertarafRaporTarihi  Section



Gui, Add, Text, x12 y90 w320 h17 , Bertaraf Şirketi
Gui, Add, ComboBox, x12 y105 w320 h90 vBertaraf gSubmit_All, % bertarafs
Gui, Add, Text, x342 y90 w130 h17 , Bertaraf Şirketi Kodu
Gui, Add, Edit, x342 y105 w130 h20 vBertarafKodu, 

Gui, Add, Button, x892 y10 w100 h30 gtemizle, Clear



Gui, Add, Button, x1002 y10 w100 h30 gEkle, Add
Gui, Add, Button, x1002 y50 w100 h30 gButtonEdit, Edit
Gui, Add, Button, x1002 y90 w100 h30 gSil, Delete


Gui, Add, ListView, x12 y190 w1200 h580 -Multi AltSubmit LV0x1 gLV, ID#|BARKOD|PLAKA NO|BELGE NO|T.C./VERGİ NO|Vekil T.C./Vergi Numarası|Noterlik Adı|Yevmiye No|Yevmiye Tarihi|Rapor Tarihi|Bertaraf Şirketi|Bertaraf Kodu
Gui, Add, Text, x12 y770 w200 h20 , Aktif Kayıt Adedi :



;FillLV

IniRead, list, %f%, Count, list
Loop, Parse, list, |
{
 If !A_LoopField
  continue
 IniRead, BARKOD , %f%, %A_LoopField%, BARKOD
 IniRead, PlakaNo, %f%, %A_LoopField%, Plaka Numarası
 IniRead, BelgeNo  , %f%, %A_LoopField%, Belge Seri Numarası
 IniRead, TCVergiNo, %f%, %A_LoopField%, T.C. Kimlik/Vergi Numarası
 IniRead, VekilTCVergiNo , %f%, %A_LoopField%, Vekil T.C./Vergi Numarası
 IniRead, NoterlikAdi, %f%, %A_LoopField%, Noterlik Adı
 IniRead, YevmiyeNo, %f%, %A_LoopField%, Yevmiye No
 IniRead, YevmiyeTarihi, %f%, %A_LoopField%, Yevmiye Tarihi
 IniRead, BertarafRaporTarihi, %f%, %A_LoopField%, Bertaraf Rapor Tarihi
 IniRead, Bertaraf, %f%, %A_LoopField%, Bertaraf Şirketi
 IniRead, BertarafKodu, %f%, %A_LoopField%, Bertaraf Şirketi Kodu
 
 LV_Add("",A_LoopField,BARKOD,PlakaNo,BelgeNo,TCVergiNo,VekilTCVergiNo,NoterlikAdi,YevmiyeNo,YevmiyeTarihi,BertarafRaporTarihi,Bertaraf,BertarafKodu)
}

 Gui, Submit, NoHide
 Arr := StrSplit(BARKOD, "*")
   loop, 3
        GuiControl,,PlakaNo, % Arr[a_index-1]
        GuiControl,,BelgeNo, % Arr[a_index+1]
        GuiControl,,TCVergiNo, % Arr[a_index+3]


Gui, Show, w1227 h814, ARTES X
return




GuiClose:
ExitApp

GuiSize:
LV_ModifyCol(1,0)
Loop,11
LV_ModifyCol(A_Index+1,"AutoHdr")

Return


Submit_All:
Gui, Submit, NoHide
ToolTip, % Bertaraf
return

BarkodOkut:
 Gui, Submit, NoHide
 Arr := StrSplit(BARKOD, "*")
   loop, 3
        GuiControl,,PlakaNo, % Arr[a_index-1]
        GuiControl,,BelgeNo, % Arr[a_index+1]
        GuiControl,,TCVergiNo, % Arr[a_index+3]
 
return


LV:


Gui, Submit, NoHide
;~ FormatTime, YevmiyeTarihi,, dd/MM/yyyy
;~ FormatTime, BertarafRaporTarihi,, dd/MM/yyyy
  
    
RowNumber := LV_GetNext()
 If !RowNumber
  return
 LV_GetText(ID, RowNumber, 1)
 LV_GetText(BARKOD, RowNumber, 2)
 LV_GetText(PlakaNo, RowNumber, 3)
 LV_GetText(BelgeNo, RowNumber, 4)
 LV_GetText(TCVergiNo, RowNumber, 5)
 LV_GetText(VekilTCVergiNo, RowNumber, 6)
 LV_GetText(NoterlikAdi, RowNumber, 7)
 LV_GetText(YevmiyeNo, RowNumber, 8)
 LV_GetText(YevmiyeTarihi, RowNumber, 9)
 LV_GetText(BertarafRaporTarihi, RowNumber, 10)
 LV_GetText(Bertaraf, RowNumber, 11)
 LV_GetText(BertarafKodu, RowNumber, 12)


 GuiControl,, BARKOD, %BARKOD%
 GuiControl,, PlakaNo, %PlakaNo%
 GuiControl,, BelgeNo, %BelgeNo%
 GuiControl,, TCVergiNo, %TCVergiNo%
 GuiControl,, VekilTCVergiNo, %VekilTCVergiNo%
 GuiControl,, NoterlikAdi, %NoterlikAdi%
 GuiControl,, YevmiyeNo, %YevmiyeNo%
 FormatTime, YevmiyeTarihi, %YevmiyeTarihi%, dd/MM/yyyy
 GuiControl,, YevmiyeTarihi, %YevmiyeTarihi%
 GuiControl,, BertarafRaporTarihi, %BertarafRaporTarihi%

 GuiControl,, Bertaraf, %Bertaraf%
 GuiControl, Text, Bertaraf, %Bertaraf%
 GuiControl,, BertarafKodu, %BertarafKodu%
 

 
 Gui, Submit, NoHide
 Arr := StrSplit(BARKOD, "*")
   loop, 3
        GuiControl,,PlakaNo, % Arr[a_index-1]
        GuiControl,,BelgeNo, % Arr[a_index+1]
        GuiControl,,TCVergiNo, % Arr[a_index+3]
        
        
 If A_GuiEvent != DoubleClick        
 ;~ gosub HurdaRapor
 ;~ gosub HurdaSonuç
 ;~ gosub temizle
        
return

Ekle:
 WinGetActiveTitle, title
 Gui, Submit, NoHide
 
 If !BARKOD
  return

Gui, 1:Default
 
 
 If (title = "ARTES X") {

  IniRead, ID, %f%, Count, ID#
  IniWrite,% ++ID, %f%, Count, ID#
  IniRead, list, %f%, Count, list
  IniWrite,% list ID "|", %f%, Count, list
  LV_Add("",ID,BARKOD,PlakaNo,BelgeNo,TCVergiNo,VekilTCVergiNo,NoterlikAdi,YevmiyeNo,YevmiyeTarihi,BertarafRaporTarihi,Bertaraf,BertarafKodu)

	
 } 
 Else LV_Modify(RowNumber,"",ID,BARKOD,PlakaNo,BelgeNo,TCVergiNo,VekilTCVergiNo,NoterlikAdi,YevmiyeNo,YevmiyeTarihi,BertarafRaporTarihi,Bertaraf,BertarafKodu)
 IniWrite, %BARKOD% , %f%, %ID%, BARKOD
 IniWrite, %PlakaNo% , %f%, %ID%,  Plaka Numarası
 IniWrite, %BelgeNo% , %f%, %ID%, Belge Seri Numarası
 IniWrite, %TCVergiNo% , %f%, %ID%, T.C. Kimlik/Vergi Numarası
 IniWrite, %VekilTCVergiNo%, %f%, %ID%, Vekil T.C./Vergi Numarası
 IniWrite, %NoterlikAdi% , %f%, %ID%, Noterlik Adı
 IniWrite, %YevmiyeNo% , %f%, %ID%, Yevmiye No
 IniWrite, %YevmiyeTarihi% , %f%, %ID%, Yevmiye Tarihi
 IniWrite, %BertarafRaporTarihi% , %f%, %ID%, Bertaraf Rapor Tarihi
 IniWrite, %Bertaraf% , %f%, %ID%, Bertaraf Şirketi
 IniWrite, %BertarafKodu% , %f%, %ID%, Bertaraf Şirketi Kodu

for i, c in ["BARKOD", "PlakaNo", "BelgeNo", "TCVergiNo", "VekilTCVergiNo", "NoterlikAdi", "YevmiyeNo", "YevmiyeTarihi", "BertarafRaporTarihi", "Bertaraf", "BertarafKodu"] { ; Clear these edit boxes
			%c% := ""
	GuiControl,, %c%, % %c%
}
	GuiControl, Focus, BARKOD

return

Sil:
 RowNumber := LV_GetNext()
 If !RowNumber
  return
 Gui, +OwnDialogs
 Msgbox,4, SİL, Silmek istediğinizden emin misiniz ?
 IfMsgBox, No
  return
 LV_GetText(ID,RowNumber)
 IniRead, list, %f%, Count, list
 StringReplace, list, list, |%ID%|, |
 IniWrite, %list%, %f%, Count, list
 IniDelete, %f%, %ID%
 LV_Delete(RowNumber)
return


ButtonEdit:
Gui, Submit, NoHide

LV_Modify(RowNumber,"",ID,BARKOD,PlakaNo,BelgeNo,TCVergiNo,VekilTCVergiNo,NoterlikAdi,YevmiyeNo,YevmiyeTarihi,BertarafRaporTarihi,Bertaraf,BertarafKodu)

 IniWrite, %BARKOD% , %f%, %ID%, BARKOD
 IniWrite, %PlakaNo% , %f%, %ID%,  Plaka Numarası
 IniWrite, %BelgeNo% , %f%, %ID%, Belge Seri Numarası
 IniWrite, %TCVergiNo% , %f%, %ID%, T.C. Kimlik/Vergi Numarası
 IniWrite, %VekilTCVergiNo%, %f%, %ID%, Vekil T.C./Vergi Numarası
 IniWrite, %NoterlikAdi% , %f%, %ID%, Noterlik Adı
 IniWrite, %YevmiyeNo% , %f%, %ID%, Yevmiye No
 IniWrite, %YevmiyeTarihi% , %f%, %ID%, Yevmiye Tarihi
 IniWrite, %BertarafRaporTarihi% , %f%, %ID%, Bertaraf Rapor Tarihi
 IniWrite, %Bertaraf% , %f%, %ID%, Bertaraf Şirketi
 IniWrite, %BertarafKodu% , %f%, %ID%, Bertaraf Şirketi Kodu
 
 GuiControl,     , BARKOD, %BARKOD%
 GuiControl,     , PlakaNo, %PlakaNo%
 GuiControl,     , BelgeNo, %BelgeNo%
 GuiControl,     , TCVergiNo, %TCVergiNo%
 GuiControl,     , VekilTCVergiNo, %VekilTCVergiNo%
 GuiControl,     , NoterlikAdi, %NoterlikAdi%
 GuiControl,     , YevmiyeNo, %YevmiyeNo%
 GuiControl,     , YevmiyeTarihi, %YevmiyeTarihi%
 GuiControl,     , BertarafRaporTarihi, %BertarafRaporTarihi%
 GuiControl, Text, Bertaraf, %Bertaraf%
 GuiControl,     , BertarafKodu, %BertarafKodu%

return
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: About datetime format for Listview

15 Aug 2018, 07:36

Otherwise, specify all or the leading part of a timestamp in the YYYYMMDDHH24MISS format. If the date and/or time portion of the timestamp is invalid -- such as February 29th of a non-leap year -- the date and/or time will be omitted from OutputVar.
https://autohotkey.com/docs/commands/FormatTime.htm
In order to get the correct format of the time from the ini file you have to have it in at least the YYYYMMDD format, so your ini file time should be inputted like 20180101 so when formattime happens it can format the time into the date you want.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: About datetime format for Listview

15 Aug 2018, 08:31

Hello chngrcn.

Your script looks nice. I solved your issue by adding two lines and two new variable names.
Please look here:

Code: Select all

Ekle:
 WinGetActiveTitle, title
 Gui, Submit, NoHide
 
 If !BARKOD
  return

Gui, 1:Default
 FormatTime, YevmiyeTarihi_DATE, YevmiyeTarihi, dd/MM/yyyy			; <-- Add this line
 FormatTime, BertarafRaporTarihi_DATE, BertarafRaporTarihi, dd/MM/yyyy	; <-- Add this line
 
 If (title = "ARTES X") {

  IniRead, ID, %f%, Count, ID#
  IniWrite,% ++ID, %f%, Count, ID#
  IniRead, list, %f%, Count, list
  IniWrite,% list ID "|", %f%, Count, list
  
  LV_Add("",ID,BARKOD,PlakaNo,BelgeNo,TCVergiNo,VekilTCVergiNo,NoterlikAdi,YevmiyeNo,YevmiyeTarihi_DATE,BertarafRaporTarihi_DATE,Bertaraf,BertarafKodu) ; Please notice the changed variable name. You have to do this even for the next [c]LV_Add(..)[/c]-command.
  ...
EDIT: There is a little fault, when you doubleclick on ListView.
Add a return-command, and it will be fixed.

Code: Select all

...
If A_GuiEvent != DoubleClick        
 ;~ gosub HurdaRapor
 ;~ gosub HurdaSonuç
 ;~ gosub temizle
 return		; <-- Add this return for the "if"-statement before, otherwise it will start next label called "Ekle:"
 return
Einfach nur ein toller Typ. :mrgreen:
chngrcn
Posts: 190
Joined: 29 Feb 2016, 08:55

Re: About datetime format for Listview

16 Aug 2018, 01:33

Thank you Divanebaba..

but when I press the add button "DateTime" I can not see the date I selected in the ListView. I also have the same problem when I press the edit button at the same time ..

I would like to add it to the ListView if I choose a Date from DateTime and the format will be dd / MM / yyyy

The date in the listview and datetime should be displayed this way;
for example: 01/01/2018

also,

Can we display the names of all active records in the listview list?

Code: Select all

Gui, Add, Text, x12 y770 w200 h20, Aktif kayıt adedi:
LV_GetCount() ?

also,
How can we make the listview select the last line when the menu is opened?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: CrowexBR, doodles333, vysmaty and 248 guests