Example #1
0
    public TimeDate secondsToDate(ulong inputSeconds)
    {
        TimeDate date = new TimeDate();

        byte tmp = (byte)(inputSeconds % seconds_per_minute);

        date.second = tmp;

        tmp         = (byte)((inputSeconds % seconds_per_hour - date.second) / seconds_per_minute);
        date.minute = tmp;

        tmp       = (byte)((inputSeconds % seconds_per_day - date.minute - date.second) / seconds_per_hour);
        date.hour = tmp;

        ushort tmp2 = (ushort)((inputSeconds % seconds_per_year - date.minute - date.second - date.hour) / seconds_per_day);

        date.day = tmp2;

        ulong tmp3 = (ulong)(inputSeconds / seconds_per_year);

        date.year = tmp3;


        tmp          = (byte)(date.day % days_per_week);
        date.weekday = tmp;

        tmp         = (byte)((inputSeconds % seconds_per_year) / seconds_per_season);
        date.season = tmp;

        return(date);
    }
        public void WrongWord()
        {
            TimeDate Actual   = _convertTimeAreaWord.ConvertTimeAreaWordToTimeArea("Test");
            TimeDate Expected = null;

            Assert.Equal(expected: Expected, actual: Actual);
        }
Example #3
0
 protected void init()
 {
     Debug.Log("Time_Manager.init()");
     TimeData = new GameTime();
     timeDate = new TimeDate();
     setTimeState(TimeState.paused);
     timeScale = 1.0f;
 }
        public void FromSeconds()
        {
            float    seconds0 = 0.00015F;
            TimeDate date     = TimeDate.FromSeconds(seconds0);
            float    seconds1 = date.TotalSeconds;

            Assert.AreEqual(seconds0, seconds1);
        }
Example #5
0
 public SGP4Thread(Tle tleData,
                   TimeDate starttime, TimeDate stoptime, double step)
 {
     satTleData = tleData;
     startTime  = starttime;
     stopTime   = stoptime;
     tick       = step;
 }
Example #6
0
 public SGP4Thread(SatelliteDataVector dataVector, Tle tleData,
                   TimeDate starttime, TimeDate stoptime, double step)
 {
     satTleData    = tleData;
     startTime     = starttime;
     stopTime      = stoptime;
     tick          = step;
     dataVectorRes = dataVector;
 }
        public void LastMonth()
        {
            TimeDate Actual   = _convertTimeAreaWord.ConvertTimeAreaWordToTimeArea("LastMonth");
            TimeDate Expected = new TimeDate
            {
                StartDate = new DateTime(2014, 11, 01),
                EndDate   = new DateTime(2014, 11, 30)
            };

            Assert.Equal(expected: Expected, actual: Actual);
        }
        public void LastWeek()
        {
            TimeDate Actual   = _convertTimeAreaWord.ConvertTimeAreaWordToTimeArea("LastWeek");
            TimeDate Expected = new TimeDate
            {
                StartDate = new DateTime(2014, 12, 13),
                EndDate   = new DateTime(2014, 12, 20)
            };

            Assert.Equal(expected: Expected, actual: Actual);
        }
        public void Yesterday()
        {
            TimeDate Actual   = _convertTimeAreaWord.ConvertTimeAreaWordToTimeArea("Yesterday");
            TimeDate Expected = new TimeDate
            {
                StartDate = new DateTime(2014, 12, 23),
                EndDate   = new DateTime(2014, 12, 24)
            };

            Assert.Equal(expected: Expected, actual: Actual);
        }
Example #10
0
 public void testFuckShit2()
 {
     SGP4.Sgp4 sgp = new SGP4.Sgp4(satTleData, 0);
     sgp.runSgp4Cal(startTime, stopTime, tick / 60.0);
     results = new List <Sgp4Data>(sgp.getRestults());
     sgp.clear();
     sgp           = null;
     satTleData    = null;
     startTime     = null;
     stopTime      = null;
     dataVectorRes = null;
 }
Example #11
0
        /// <summary>
        /// 定时转字符串
        /// </summary>
        /// <returns>字符串</returns>
        public override string ToString()
        {
            List <string> tr = new List <string>();

            tr.Add(TimedMode.ToString());
            tr.Add(TimeLoop.ToString());
            tr.Add(TimeDate.ToString());
            tr.Add(Mark);
            tr.Add(StartTime.ToString());
            tr.Add(EndTime.ToString());
            tr.Add(Status.ToString());
            return(string.Join("|", tr.ToArray()));
        }
Example #12
0
        /// <summary>
        /// Sets an event definition for the timer with a time date.
        /// </summary>
        /// <param name="timerDate"> the time date of the timer </param>
        /// <returns> the builder object </returns>
        public virtual B timerWithDate(string timerDate)
        {
            TimeDate timeDate = createInstance(typeof(TimeDate));

            timeDate.TextContent = timerDate;

            TimerEventDefinition timerEventDefinition = createInstance(typeof(TimerEventDefinition));

            timerEventDefinition.TimeDate = timeDate;

            element.EventDefinitions.add(timerEventDefinition);

            return(myself);
        }
Example #13
0
    protected void init()
    {
        Alive           = true;
        region          = 0;
        birthday        = new TimeDate();
        age             = new TimeDate();
        actorValues     = new List <ActorValue>();
        personalityData = new Actor_Personality(); //TODO: this can be optional at some point
        breedData       = new Actor_BreedData();   //TODO: this can be optional at some point

        //DEBUG
        initToDefault();
        setRandomActor();
    }
Example #14
0
        public void ZdaDecode()
        {
            _lastPacketTime = DateTimeOffset.UtcNow;
            string text    = "$GPZDA,135302.036,02,02,2020,+01,00*7F";
            var    decoded = TalkerSentence.FromSentenceString(text, out var error);

            Assert.Equal(NmeaError.None, error);
            Assert.NotNull(decoded);

            TimeDate zda = (TimeDate)decoded !.TryGetTypedValue(ref _lastPacketTime) !;

            Assert.True(zda.Valid);
            Assert.Equal(1.0, zda.LocalTimeOffset.TotalHours);
            Assert.Equal(new DateTime(2020, 02, 02, 13, 53, 02, 36, DateTimeKind.Utc), zda.DateTime);
        }
Example #15
0
        public override string ToString()
        {
            StringBuilder printPost = new StringBuilder();

            printPost.AppendLine(Title);
            printPost.Append(Like);
            printPost.Append(" Likes - ");
            printPost.AppendLine(TimeDate.ToString("dd/MM/yyyy HH:mm:ss"));
            printPost.AppendLine(Content);
            printPost.AppendLine("Commentários: ");
            foreach (Comments element in Comment)
            {
                printPost.AppendLine(element.Text);
            }
            return(printPost.ToString());
        }
Example #16
0
        public void ZdaDecodeNoTime()
        {
            _lastPacketTime = DateTimeOffset.UtcNow;
            DateTimeOffset start   = _lastPacketTime;
            string         text    = "$GPZDA,,,,,,*48";
            var            decoded = TalkerSentence.FromSentenceString(text, out var error);

            Assert.Equal(NmeaError.None, error);
            Assert.NotNull(decoded);

            TimeDate zda = (TimeDate)decoded !.TryGetTypedValue(ref _lastPacketTime) !;

            Assert.False(zda.Valid);
            Assert.Equal(0, zda.LocalTimeOffset.TotalHours);
            Assert.Equal(start, _lastPacketTime); // Should not have changed
        }
Example #17
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty propertyValue = property.FindPropertyRelative("m_value");

            ulong  value = (ulong)propertyValue.longValue;
            var    time  = new TimeDate(value);
            var    date  = new DateTime(time.Ticks);
            string text  = date.ToString("O");

            text = EditorGUI.DelayedTextField(position, label, text);

            if (DateTime.TryParse(text, out date))
            {
                time = date;

                propertyValue.longValue = (long)time.Value;
            }
        }
Example #18
0
    public void setRandomActor()
    {
        //DEBUG: hardcoded values everywhere
        name              = NameGenerator.RandomName();
        region            = (ushort)Random.Range(1, 10);
        ageInSeconds      = (ulong)Random.Range(0, 100 * GameTime.singleton.seconds_per_year);
        age               = GameTime.singleton.secondsToDate(ageInSeconds);
        birthdayInSeconds = GameTime.singleton.Time - ageInSeconds;
        birthday          = GameTime.singleton.secondsToDate(birthdayInSeconds);
        ageInSecondsMax   = (ulong)Random.Range(ageInSeconds + 5 * GameTime.singleton.seconds_per_year, 120 * GameTime.singleton.seconds_per_year);

        decayTimeMax  = (ulong)(0.5 * GameTime.singleton.seconds_per_year);
        deleteTimeMax = (ulong)(2 * GameTime.singleton.seconds_per_year);

        position = new Vector3(Random.Range(-20.0f, 20.0f), Random.Range(-20.0f, 20.0f), Random.Range(-20.0f, 20.0f));

        breedData.makeRandomBreedData();
        personalityData.makeRandomPersonality();
    }
Example #19
0
        private void SendNewData()
        {
            try
            {
                var data = _activeData;
                RecommendedMinimumNavigationInformation rmc = new RecommendedMinimumNavigationInformation(DateTimeOffset.UtcNow,
                                                                                                          NavigationStatus.Valid, data.Position,
                                                                                                          data.Speed, data.Course, null);
                SendSentence(rmc);

                GlobalPositioningSystemFixData gga = new GlobalPositioningSystemFixData(
                    DateTimeOffset.UtcNow, GpsQuality.DifferentialFix, data.Position, data.Position.EllipsoidalHeight - 54,
                    2.5, 10);
                SendSentence(gga);

                TimeDate zda = new TimeDate(DateTimeOffset.UtcNow);
                SendSentence(zda);
            }
            catch (IOException x)
            {
                Console.WriteLine($"Error writing to the output stream: {x.Message}. Connection lost.");
            }
        }
Example #20
0
 public ClockDate AddDays(double value)
 {
     return(new ClockDate(TimeDate.AddDays(value)));
 }
        public void OneTickSeconds()
        {
            TimeDate date = TimeDate.FromTicks(1L);

            Assert.AreEqual(0.0000001F, date.TotalSeconds);
        }
        public void FromSecondsOneTick()
        {
            TimeDate date = TimeDate.FromSeconds(0.0000001F);

            Assert.AreEqual(1L, date.Ticks);
        }
Example #23
0
 private void UpdateCurrentDate()
 {
     CurrentDate = secondsToDate(Time);
 }
Example #24
0
 public static long DateToSeconds(TimeDate dateToSpan)
 {
     return(0);
 }
Example #25
0
 public Time_Span(TimeDate dateToSeconds)
 {
 }
Example #26
0
 public ClockDate AddSeconds(int value)
 {
     return(new ClockDate(TimeDate.AddSeconds(value)));
 }
Example #27
0
        static void Main(string[] args)
        {
            ReadCommandLineArguments readCommandLineArguments = new ReadCommandLineArguments(
                checkDateExist: new CheckDateExist());
            bool     help      = readCommandLineArguments.ReadHelp(args);
            bool     entries   = readCommandLineArguments.ReadEntries(args);
            string   write     = readCommandLineArguments.ReadWrite(args);
            DateTime startDate = readCommandLineArguments.ReadStartDate(args);
            DateTime endDate   = readCommandLineArguments.ReadEndDate(args);
            string   timearea  = readCommandLineArguments.ReadTimeArea(args);

            ConvertTimeAreaWord convertTimeAreaWord = new ConvertTimeAreaWord(
                dateTimeHelper: new DateTimeHelper());



            ReadListApiKey readListApiKey = new ReadListApiKey(
                readJsonData: new ReadJsonData(),
                convertJsonToList: new ConvertJsonStringToListUsers()
                );
            List <Users> userlist = readListApiKey.Execute();

            if (args.Length == 0)
            {
                WriteUserApiKeyConsol writeUserApiKeyConsol = new WriteUserApiKeyConsol(
                    formatTextForConsol: new FormatUserTextForConsol(),
                    writeConsol: new WriteConsol()
                    );
                writeUserApiKeyConsol.WriteConsol(userlist);
            }

            if (timearea != null)
            {
                TimeDate date = convertTimeAreaWord.ConvertTimeAreaWordToTimeArea(timearea);
                startDate = date.StartDate;
                endDate   = date.EndDate;
            }


            if (help == true)
            {
                WriteHelpConsol writeHelpConsol = new WriteHelpConsol(
                    formatHelpTextForConsol: new FormatHelpTextForConsol(),
                    writeConsol: new WriteConsol());
                writeHelpConsol.WriteHelp();
            }


            if (entries == true)
            {
                ReadAllDataFromAllUsers readAllDataFromAllUsers = new ReadAllDataFromAllUsers(
                    getConnectionToggl: new GetConnectionToggl()
                    );
                List <Item> allInfoList = readAllDataFromAllUsers.ReadAll(userlist);

                ReadAllTime_Entries readAllTime_Entries = new ReadAllTime_Entries(
                    getConnectionToggl: new GetConnectionToggl()
                    );
                List <Time_entriesItem> timeList = readAllTime_Entries.ReadAll(userlist, startDate: startDate, endDate: endDate);

                ReadAllProjects readAllProjects = new ReadAllProjects(
                    getConnectionToggl: new GetConnectionToggl()
                    );
                List <ProjectsItem> projectsList = readAllProjects.ReadAll(userlist, timeList);

                ReadAllClients readAllClients = new ReadAllClients(
                    getConnectionToggl: new GetConnectionToggl()
                    );
                List <ClientsItem> clientsList = readAllClients.ReadClients(userlist, projectsList);

                if (write != null)
                {
                    WriteAllDataFromAllUserCSVFile writeAllDataFromAllUserCSVFile = new WriteAllDataFromAllUserCSVFile(
                        convertListToCSV: new ConvertListToCSV(),
                        writeFile: new WriteFile(),
                        writeConsol: new WriteConsol());
                    writeAllDataFromAllUserCSVFile.SaveData(allInfoList, timeList, projectsList, clientsList, write);
                }
                else
                {
                    WriteTime_EntriesConsol writeTime_EntriesConsol = new WriteTime_EntriesConsol(
                        formatTime_EntriesForConsol: new FormatTime_EntriesForConsol(),
                        writeConsol: new WriteConsol());
                    writeTime_EntriesConsol.WriteTime(timeList);
                }
            }
            Console.ReadLine();
        }
Example #28
0
 public ClockDate AddYears(int value)
 {
     return(new ClockDate(TimeDate.AddYears(value)));
 }
Example #29
0
 public override string ToString()
 {
     return($"{TimeDate.ToShortDateString()}, {TimeDate.ToShortTimeString()}, PM2.5 = {Pm2_5Amount.ToString("G2").PadLeft(6,' ')} ug/m3, PM10 = {Pm10Amount.ToString("G2").PadLeft(6, ' ')} ug/m3, ID = 0x{ID.ToString("X4")}");
 }