omseven / JDate

Jalali Date For Arduino (Persian Date)
14 stars 2 forks source link

how use string or somting to import time (ex ds3231) to jalali #1

Open majidmp97 opened 6 years ago

majidmp97 commented 6 years ago

hello (سلام مهندس ) how can i convert rtc time to jalali with your cod? looklike this

include

DS3231_Simple Clock; ///jalali date shamsi

include "JDateLib.h"

String jdate; // Jalali Date String int JY, JM, JD; // Jalali Year & Month & Day Intiger String timsd; //use for put time togather and convert to shamsi int Ytim = ""; int Montim = ""; int Dtim = ""; int Htim = ""; int Mintim = ""; void setup() { Clock.begin(); }

void readtime() { DateTime MyDateAndTime; MyDateAndTime = Clock.read(); Ytim = (MyDateAndTime.Year); Montim = (MyDateAndTime.Month); Dtim = (MyDateAndTime.Day); Htim = (MyDateAndTime.Hour); Mintim = (MyDateAndTime.Minute);

// conver to jalali timsd +="20"; timsd +=Ytim; timsd +=", "; timsd +=Montim ; timsd +=", "; timsd +=Dtim ;

Date now(2018, 07, 31); Ytim = (MyDateAndTime.Year); Montim = (MyDateAndTime.Month); Dtim = (MyDateAndTime.Day); Htim = (MyDateAndTime.Hour); Mintim = (MyDateAndTime.Minute);

// conver to jalali timsd +="20"; timsd +=Ytim; timsd +=", "; timsd +=Montim ; timsd +=", "; timsd +=Dtim ;

Date now(timsd); jdate = now.JDate(); JY = now.JYear(); JM = now.JMonth(); JD = now.JDay(); //Serial.println(JY); //Serial.println(JM); //Serial.println(JD); Serial.println(jdate); } void loop () { readtime(); }

barbodar commented 4 years ago

I think best way is to convert epoch to normal date after that use the normal date to convert to jalali

AmirRezaKhezli commented 2 years ago

عالی تو اکثر پروژه هام استفاده میکنم ازش 👏👏👏