本文整理汇总了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);
}
示例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));
}
示例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();
}
示例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();
}
示例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());
}
示例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));
}
示例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();
}
示例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();
}