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


C# DateTime.ToTimestamp方法代码示例

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


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

示例1: TestConversion

        public void TestConversion()
        {
            DateTime dt = new DateTime(2013, 1, 16, 14, 20, 0);
            long ts = dt.ToTimestamp();

            Assert.AreEqual(ts, 1358346000000);

            DateTime cdt = ts.ToDateTime();
            Assert.AreEqual(cdt, dt);
        }
开发者ID:Jacky1,项目名称:cassandra-sharp,代码行数:10,代码来源:DateTimeExtensionsTest.cs

示例2: Convert_correctly_converts_RequestDate

        public void Convert_correctly_converts_RequestDate()
        {
            // arrange
            var requestDate = new DateTime(2011, 2, 3, 15, 3, 21);
            var ts = requestDate.ToTimestamp();
            var request = new PortfolioCalculationRequest { RequestTimestamp = ts  };
            var provider = new PortfolioCalculationRequestProvider();

            // act
            var model = provider.Convert(request);

            // assert
            Assert.That(model.RequestTimestamp, Is.EqualTo(ts));
        }
开发者ID:jrolstad,项目名称:Motore,代码行数:14,代码来源:PortfolioCalculationRequestProviderTests.cs

示例3: GetPhotoPostsAsync

        public async Task<List<dynamic>> GetPhotoPostsAsync(string tag, DateTime before, int limit)
        {
            var timestamp = before.ToTimestamp();
            var q = $"tag={tag}&before={timestamp}&limit={limit}&api_key={_apiKey}";

            string url = $"{BaseUrl}/tagged?{q}";
            var posts = await _httpClient.GetAsync(url);

            return ((IEnumerable<dynamic>) posts.response)
                .Where(p => p.type == "photo" &&
                            DynamicHelper.HasProperty(() => p.image_permalink) &&
                            (p.image_permalink != null && p.image_permalink.ToString() != string.Empty))
                .ToList();
        }
开发者ID:sbrydon,项目名称:Norbert,代码行数:14,代码来源:TumblrClient.cs

示例4: GetInterval

        /// <summary>
        /// 
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public IQueryable<Market> GetInterval(DateTime @from, DateTime to)
        {
            var filename = PathResolver.GetFilename(to);

            return LoadData(line =>
            {
                var date = Parser.ParseDate(line);
                if (date <= to.ToTimestamp() && date >= from.ToTimestamp())
                {
                    return Parser.ParseRecord(line);
                }
                return null;
            }, filename).AsQueryable();
        }
开发者ID:vtalas,项目名称:marketgarden,代码行数:20,代码来源:MarketDataLoader.cs

示例5: xxx_test

        public void xxx_test()
        {
            var x = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            var now = DateTime.Now;

            //long timestamp = 1380483372;
            const long timestamp = 0;
            Console.WriteLine(x);

            Console.WriteLine(x.ToTimestamp());
            Console.WriteLine("xx");
            Console.WriteLine(x.ToUniversalTime().ToTimestamp());
            Console.WriteLine(timestamp.ToDateTime().ToLocalTime());
            Console.WriteLine(timestamp.ToDateTime());
        }
开发者ID:vtalas,项目名称:marketgarden,代码行数:15,代码来源:DateTimeExtension_test.cs

示例6: ConvertToPortfolioFileInfo_sets_UploadTimestamp_from_current_time

        public void ConvertToPortfolioFileInfo_sets_UploadTimestamp_from_current_time()
        {
            // arrange
            var dt = new DateTime(2011, 4, 1, 9, 33, 21);
            var ts = dt.ToTimestamp();
            SystemTime.Now = () => dt;
            var putInfo = new S3PutInfo();
            var provider = new PortfolioCalculationRequestProvider();

            // act

            var actual = provider.ConvertToPortfolioFileInfo(putInfo);

            // assert
            Assert.That(actual.UploadTimestamp, Is.EqualTo(ts));
        }
开发者ID:jrolstad,项目名称:Motore,代码行数:16,代码来源:PortfolioCalculationRequestProviderTests.cs

示例7: SavePortfolioFile_calls_correct_methods

        public void SavePortfolioFile_calls_correct_methods()
        {
            // arrange
            var dt = new DateTime(2011, 4, 1, 9, 33, 21);
            SystemTime.Now = () => dt;
            var savePath = "foobarbat";
            var clientFileName = "zeezing";

            var putInfo = MockRepository.GenerateMock<S3PutInfo>();
            var fileInfo = MockRepository.GenerateMock<PortfolioFileInfo>();
            fileInfo.Expect(f => f.UploadTimestamp).Return(dt.ToTimestamp());

            var s3Client = MockRepository.GenerateStub<S3Client>(null, null);
            s3Client.Expect(s => s.Save(null, null, null)).IgnoreArguments().Return(putInfo);

            var model = MockRepository.GenerateStub<PortfolioCalculationRequestInputModel>();
            model.Expect(m=>m.ClientFileName).Return(clientFileName);

            var provider = MockRepository.GenerateMock<PortfolioCalculationRequestProvider>();
            provider.Expect(p => p.S3Client).Return(s3Client);
            provider.Expect(p => p.CalculatePortfolioFileSavePath(model)).Return(savePath);
            provider.Expect(p => p.ConvertToPortfolioFileInfo(putInfo)).Return(fileInfo);
            provider.Expect(p => p.SavePortfolioFile(model)).CallOriginalMethod(OriginalCallOptions.CreateExpectation);

            // act
            provider.SavePortfolioFile(model);

            // assert
            s3Client.VerifyAllExpectations();
            model.VerifyAllExpectations();
            provider.VerifyAllExpectations();
        }
开发者ID:jrolstad,项目名称:Motore,代码行数:32,代码来源:PortfolioCalculationRequestProviderTests.cs

示例8: GetFlotData

        IEnumerable<Flot> GetFlotData(DateTime aStart, DateTime aEnd)
        {
            var tObjects = new List<Flot>();

            FetchData data = Helper.RrdDb.createFetchRequest(ConsolFuns.CF_AVERAGE, aStart.ToTimestamp(), aEnd.ToTimestamp(), 1).fetchData();
            Int64[] times = data.getTimestamps();
            double[][] values = data.getValues();

            for (int a = 1; a <= Snapshot.SnapshotCount; a++)
            {
                var obj = new Flot();

                var list = new List<double[]>();
                for (int b = 0; b < times.Length; b++)
                {
                    double[] current = { times[b] * 1000, values[a][b] };
                    list.Add(current);
                }
                obj.Data = list.ToArray();
                obj.Type = a;

                tObjects.Add(obj);
            }

            return tObjects.ToArray();
        }
开发者ID:scottc,项目名称:xdcc-grabscher,代码行数:26,代码来源:SnapshotHub.cs


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