#property script_show_inputs input int InpYear = 0; // Yıl input int InpMonth = 0; // Ay input int InpDay = 0; // Gün input int InpHour = 0; // Saat input int InpMin = 0; // Dakika input int InpSec = 0; // Saniye //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- girilen değerleri ayarla ve değişkenlere yaz int year = (InpYear<1970 ? 1970 : InpYear); // girilen yıl 1970'den küçükse, 1970 kullanılır int month= (InpMonth<1 ? 1 : InpMonth > 12 ? 12 : InpMonth); int day = (InpDay <1 ? 1 : InpDay > 31 ? 31 : InpDay); int hour = (InpHour <0 ? 0 : InpHour > 23 ? 23 : InpHour); int min = (InpMin <0 ? 0 : InpMin > 59 ? 59 : InpMin); int sec = (InpSec <0 ? 0 : InpSec > 59 ? 59 : InpSec); //--- girilen değerleri günlükte görüntüle PrintFormat("Entered date and time: %04u.%02u.%02u %02u:%02u:%02u", InpYear, InpMonth, InpDay, InpHour, InpMin, InpSec); //--- düzeltilmiş girilen değerleri günlükte görüntüle PrintFormat("Corrected date and time: %04u.%02u.%02u %02u:%02u:%02u", year, month, day, hour, min, sec); //--- girdi değerlerini ilgili yapı alanlarına yaz MqlDateTime time_struct={}; time_struct.year= year; time_struct.mon = month; time_struct.day = day; time_struct.hour= hour; time_struct.min = min; time_struct.sec = sec; //--- yapıdaki tarih ve saati datetime türünde bir değişkene dönüştür ve datetime time = StructToTime(time_struct); //--- MqlDateTime yapı türündeki değişkenden datetime türünde bir değere dönüştürme sonucunu görüntüle Print("Converted date and time: ",TimeToString(time,TIME_DATE|TIME_MINUTES|TIME_SECONDS)); /* Sıfır varsayılan değeri girilirse sonuçlar: Entered date and time: 0000.00.00 00:00:00 Corrected date and time: 1970.01.01 00:00:00 Converted date and time: 1970.01.01 00:00:00 mevcut yılın şubat ayına ait yanlış bir gün girilirse sonuçlar: Entered date and time: 2024.02.31 00:00:00 Corrected date and time: 2024.02.31 00:00:00 Converted date and time: 2024.03.02 00:00:00 */ } |