using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Rds.Messages
{
    [RdsMessage(0x0d,RdsMessageHeaderType.None)]
    class RealTimeClock : RdsMessage
    {
        public RealTimeClock(byte[] buffer)
        {
            int year = buffer[0];
            byte month = buffer[1];
            byte day = buffer[2];
            byte hours = buffer[3];
            byte minutes = buffer[4];
            byte seconds = buffer[5];
            byte centiseconds = buffer[6];
            LocalTimeOffsetUnchaned = buffer[7] == 0xff;

            int yearResult = DateTime.Now.Year / 100;
            yearResult *= 100;
            yearResult += year;

            int centisecondsResult = centiseconds *= 10;

            Timestamp = new DateTime(yearResult, month, day, hours, minutes, seconds, centisecondsResult);
        }

        public bool LocalTimeOffsetUnchaned { get; private set; }

        public DateTime Timestamp { get; private set; }
    }
}
