当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeOffset.ToUnixTime方法代码示例

本文整理汇总了C#中DateTimeOffset.ToUnixTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ToUnixTime方法的具体用法?C# DateTimeOffset.ToUnixTime怎么用?C# DateTimeOffset.ToUnixTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeOffset的用法示例。


在下文中一共展示了DateTimeOffset.ToUnixTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortieStatisticCustomTimeSpanGroupViewModel

        public SortieStatisticCustomTimeSpanGroupViewModel(SortieStatisticViewModel rpOwner) : base(rpOwner, SortieStatisticTimeSpanType.Custom)
        {
            var rNow = new DateTimeOffset(DateTime.Now.AddDays(1.0).Date.AddSeconds(-1.0));

            r_SelectedDateStart = r_SelectedDateEnd = rNow.DateTime;
            TimeSpanStart = TimeSpanEnd = rNow.ToUnixTime().ToString();
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:7,代码来源:SortieStatisticCustomTimeSpanGroupViewModel.cs

示例2: ReturnsUnixEpochCorrectly

 public void ReturnsUnixEpochCorrectly()
 {
     var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
     Assert.Equal(0, epoch.ToUnixTime());
 }
开发者ID:naveensrinivasan,项目名称:octokit.net,代码行数:5,代码来源:UnixTimestampExtensionsTests.cs

示例3: ReturnsRandomDateCorrectly

 public void ReturnsRandomDateCorrectly()
 {
     var epoch = new DateTimeOffset(1975, 1, 23, 1, 1, 1, TimeSpan.Zero);
     Assert.Equal(159670861, epoch.ToUnixTime());
 }
开发者ID:naveensrinivasan,项目名称:octokit.net,代码行数:5,代码来源:UnixTimestampExtensionsTests.cs

示例4: GetTimeMachineWeatherAsync

        /// <summary>
        /// Asynchronously retrieves weather data for a particular latitude and longitude, on
        /// a given day.
        /// <para>
        /// Only conditions for the day are given (i.e. the time is ignored, and taken to be the
        /// current time).
        /// </para>
        /// <para>
        /// Allows specification of units of measurement, language used, extended hourly forecasts,
        /// and exclusion of data blocks.
        /// </para>
        /// </summary>
        /// <param name="latitude">
        /// The latitude to retrieve data for.
        /// </param>
        /// <param name="longitude">
        /// The longitude to retrieve data for.
        /// </param>
        /// <param name="date">
        /// The date to retrieve data for.
        /// </param>
        /// <param name="unit">
        /// The units of measurement to use.
        /// </param>
        /// <param name="extends">
        /// The type of forecast to retrieve extended results for. Currently limited to hourly blocks.
        /// </param>
        /// <param name="excludes">
        /// Any blocks that should be excluded from the request.
        /// </param>
        /// <param name="language">
        /// The language to use for summaries.
        /// </param>
        /// <returns>
        /// A <see cref="Task"/> for a <see cref="Forecast"/> with the requested data, or null if the data was corrupted.
        /// </returns>
        public async Task<Forecast> GetTimeMachineWeatherAsync(
            double latitude,
            double longitude,
            DateTimeOffset date,
            Unit unit,
            IList<Extend> extends,
            IList<Exclude> excludes,
            Language language)
        {
            this.ThrowExceptionIfApiKeyInvalid();

            var unitValue = unit.ToValue();
            var extendList = string.Join(",", extends.Select(x => x.ToValue()));
            var excludeList = string.Join(",", excludes.Select(x => x.ToValue()));
            var languageValue = language.ToValue();
            var unixTime = date.ToUnixTime();

            var requestUrl = string.Format(
                CultureInfo.InvariantCulture,
                SpecificTimeConditionsUrl,
                this.apiKey,
                latitude,
                longitude,
                unixTime,
                unitValue,
                extendList,
                excludeList,
                languageValue);

            return await this.GetForecastFromUrl(requestUrl);
        }
开发者ID:dfconroy,项目名称:ForecastPCL,代码行数:67,代码来源:ForecastApi.cs

示例5: CheckFileVersionAndTimestamp

        bool CheckFileVersionAndTimestamp(ResourceSession rpResourceSession, DateTimeOffset rpTimestamp)
        {
            using (var rCommand = r_Connection.CreateCommand())
            {
                rCommand.CommandText = "SELECT (CASE WHEN version IS NOT NULL THEN version ELSE '' END) = @version AND timestamp = @timestamp FROM cache.file WHERE name = @name;";
                rCommand.Parameters.AddWithValue("@name", rpResourceSession.Path);
                rCommand.Parameters.AddWithValue("@version", rpResourceSession.CacheVersion ?? string.Empty);
                rCommand.Parameters.AddWithValue("@timestamp", rpTimestamp.ToUnixTime());

                return Convert.ToBoolean(rCommand.ExecuteScalar());
            }
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:12,代码来源:CacheService.cs


注:本文中的DateTimeOffset.ToUnixTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。