本文整理匯總了C#中System.DateTime.ToOADate方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.ToOADate方法的具體用法?C# DateTime.ToOADate怎麽用?C# DateTime.ToOADate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToOADate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: formatXaxis
static void formatXaxis(ref GraphPane gPane)
{
DateTime minX = new DateTime(DateTime.Now.Year, 1, 1);
DateTime maxX = new DateTime(DateTime.Now.Year, 12,31);
double rangeX;
rangeX = maxX.ToOADate() - minX.ToOADate();
gPane.Legend.Position = LegendPos.InsideTopRight;
gPane.XAxis.Scale.Min = minX.ToOADate() - (.025 * rangeX);
gPane.XAxis.Scale.Max = maxX.ToOADate() + (.025 * rangeX);
gPane.XAxis.Scale.MajorUnit = ZedGraph.DateUnit.Month;
gPane.XAxis.Scale.MinorUnit = ZedGraph.DateUnit.Day;
gPane.XAxis.Scale.Format = "MMMM";
}
示例2: SetCellDateTime
public static void SetCellDateTime(WorksheetPart worksheetPart, DateTime value, string columnName, uint rowIndex)
{
Cell cell = GetCell(worksheetPart.Worksheet, columnName, rowIndex);
cell.CellValue = new CellValue(value.ToOADate().ToString("0.000#####"));
cell.DataType = new EnumValue<CellValues>(CellValues.Number);
}
示例3: SetCellDate
public static void SetCellDate(WorksheetPart worksheetPart, DateTime value, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row)
{
Cell cell = GetCell(worksheetPart.Worksheet, columnName, row);
cell.CellValue = new CellValue(value.ToOADate().ToString("0"));
cell.DataType = new EnumValue<CellValues>(CellValues.Number);
}
示例4: DateCell
public DateCell(string id, DateTime dateTime, uint index)
{
this.DataType = CellValues.Date;
this.CellReference = id + index;
//this.StyleIndex = 10;
this.CellValue = new CellValue { Text = dateTime.ToOADate().ToString() }; ;
}
示例5: CalculateBEPrice
public static double CalculateBEPrice(DateTime settle, DateTime maturity, decimal yield, decimal coupon)
{
var singleton = FinCADWrapper.Instance();
lock (singleton.GetLock())
{
using (SLog.NDC("aaBond_BE_p"))
{
var ret = new double[] { double.NaN };
FinCADHelpers.LogFinCADError(
FincadFunctions.aaBond_BE_p(
d_s: settle.ToOADate(),
d_m: maturity.ToOADate(),
cpn: (double)coupon * 0.01,
princ_m: 100,
yield: (double)yield,
stat: new int[] { 1 },
d_dated: 0,
d_f_cpn: 0,
return_stat: ref ret)
);
return FinCADHelpers.FinCADSingleResult(ret);
}
}
}
示例6: CreateDataPoint
private static DataPoint CreateDataPoint(double x, string axisLabel, DateTime start, DateTime end, string text, Color color) {
var point = new DataPoint(x, new double[] { start.ToOADate(), end.ToOADate() });
point.Color = color;
point.Label = text;
point.AxisLabel = axisLabel;
return point;
}
示例7: Graph
public Graph(System.Windows.Forms.CheckedListBox.CheckedItemCollection data, DateTime minDate, DateTime maxDate, ISaleService iSaleService, int mode, IReportService iReportService, ITimeSettingService iTimeSettingService, IProgramService iProgramService)
{
InitializeComponent();
fillColor(colorList);
_data = data;
_minDate = minDate;
_maxDate = maxDate;
_iSaleService = iSaleService;
_iReportService = iReportService;
_iTimeSettingService = iTimeSettingService;
_iProgramService = iProgramService;
this.chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
chart1.ChartAreas.Add("area");
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dd-MM";
chart1.ChartAreas["area"].AxisX.Interval = 1;
chart1.ChartAreas["area"].AxisX.IntervalType = DateTimeIntervalType.Days;
chart1.ChartAreas["area"].AxisX.IntervalOffset = 1;
chart1.ChartAreas["area"].AxisX.Minimum = minDate.ToOADate();
chart1.ChartAreas["area"].AxisX.Maximum = maxDate.ToOADate();
if (mode == 1)
{
drawQuantity();
label1.Text = "Quantity";
}
else
{
drawEfficiency();
label1.Text = "Efficiency";
}
}
示例8: DateCell
public DateCell(string header, DateTime dateTime, int index)
{
this.DataType = CellValues.Date;
this.CellReference = header + index;
this.StyleIndex = 1;
this.CellValue = new CellValue { Text = dateTime.ToOADate().ToString() }; ;
}
示例9: CalculatePTYield
public static double CalculatePTYield(DateTime settle, DateTime maturity, decimal price, decimal coupon)
{
var singleton = FinCADWrapper.Instance();
lock (singleton.GetLock())
{
using (SLog.NDC("aaBond_PT_y"))
{
var ret = new double[] { double.NaN };
FinCADHelpers.LogFinCADError(
FincadFunctions.aaBond_PT_intl_y(
d_s: settle.ToOADate(),
d_m: maturity.ToOADate(),
d_dated: 0,
d_f_cpn: 0,
cpn: (double) coupon*0.01,
princ: 100,
price: (double) price,
freq: 1, // annual
acc: 2, // accrual method is act/act (isda)
stat: new int[] {1}, // return the yield
return_stat: ref ret)
);
return FinCADHelpers.FinCADSingleResult(ret);
}
}
}
示例10: AddNewPoint
/// The AddNewPoint function is called for each series in the chart when
/// new points need to be added. The new point will be placed at specified
/// X axis (Date/Time) position with a Y value in a range +/- 1 from the previous
/// data point's Y value, and not smaller than zero.
public void AddNewPoint(DateTime timeStamp, System.Windows.Forms.DataVisualization.Charting.Series ptSeries, int min, int max)
{
double newVal = 0;
if (ptSeries.Points.Count > 0)
{
newVal = ptSeries.Points[ptSeries.Points.Count - 1].YValues[0] + ((rand.NextDouble() * 2) - 1);
}
if (newVal < 0)
newVal = 0;
// Add new data point to its series.
ptSeries.Points.AddXY(timeStamp.ToOADate(), rand.Next(min, max));
// remove all points from the source series older than 1.5 minutes.
double removeBefore = timeStamp.AddSeconds((double)(30) * (-1)).ToOADate();
//remove oldest values to maintain a constant number of data points
while (ptSeries.Points[0].XValue < removeBefore)
{
ptSeries.Points.RemoveAt(0);
}
chart1.ChartAreas[0].AxisX.Minimum = ptSeries.Points[0].XValue;
chart1.ChartAreas[0].AxisX.Maximum = DateTime.FromOADate(ptSeries.Points[0].XValue).AddSeconds(30).ToOADate();
chart1.ChartAreas[1].AxisX.Minimum = ptSeries.Points[0].XValue;
chart1.ChartAreas[1].AxisX.Maximum = DateTime.FromOADate(ptSeries.Points[0].XValue).AddSeconds(30).ToOADate();
chart1.ChartAreas[2].AxisX.Minimum = ptSeries.Points[0].XValue;
chart1.ChartAreas[2].AxisX.Maximum = DateTime.FromOADate(ptSeries.Points[0].XValue).AddSeconds(30).ToOADate();
chart1.Invalidate();
}
示例11: Execute
public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, ParsingContext context)
{
ValidateArguments(arguments, 2);
var date = System.DateTime.FromOADate(ArgToDecimal(arguments, 0));
var monthsToAdd = ArgToInt(arguments, 1);
var resultDate = new System.DateTime(date.Year, date.Month, 1).AddMonths(monthsToAdd + 1).AddDays(-1);
return CreateResult(resultDate.ToOADate(), DataType.Date);
}
示例12: DateFunctionShouldReturnACorrectDate
public void DateFunctionShouldReturnACorrectDate()
{
var expectedDate = new DateTime(2012, 4, 3);
var func = new Date();
var args = FunctionsHelper.CreateArgs(2012, 4, 3);
var result = func.Execute(args, _parsingContext);
Assert.AreEqual(expectedDate.ToOADate(), result.Result);
}
示例13: DateFunctionShouldMonthFromPrevYearIfMonthIsNegative
public void DateFunctionShouldMonthFromPrevYearIfMonthIsNegative()
{
var expectedDate = new DateTime(2011, 11, 3);
var func = new Date();
var args = FunctionsHelper.CreateArgs(2012, -1, 3);
var result = func.Execute(args, _parsingContext);
Assert.AreEqual(expectedDate.ToOADate(), result.Result);
}
示例14: DayShouldReturnDayInMonth
public void DayShouldReturnDayInMonth()
{
var date = new DateTime(2012, 3, 12);
var func = new Day();
var args = FunctionsHelper.CreateArgs(date.ToOADate());
var result = func.Execute(args, _parsingContext);
Assert.AreEqual(12, result.Result);
}
示例15: DateTimeToUnixTimeStamp
/// <summary>
/// Convert a Datetime to Unix Timestamp
/// </summary>
public static double DateTimeToUnixTimeStamp(DateTime time) {
double timestamp = 0;
try {
timestamp = (time - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
} catch (Exception err) {
Log.Error("Time.DateTimeToUnixTimeStamp(): " + time.ToOADate().ToString() + err.Message);
}
return timestamp;
}