示例#1
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static Altova.Types.DateTime DatetimeFromParts(int year, int month, int day, int hour, int minute, int second, decimal millisecond, int timezone)
 {
     Altova.Types.DateTime result = DatetimeAdd(new Altova.Types.DateTime(1, 1, 1), new Altova.Types.Duration(year - 1, month - 1, day - 1, hour, minute, second, (double)(millisecond * 0.001m), false));   // false means "not-negative"
     if (timezone >= -1440 && timezone <= 1440)
     {
         result.TimezoneOffset = (short)timezone;
     }
     return(result);
 }
示例#2
0
文件: Lang.cs 项目: soravroyal/EPRTR
        public static int Weekday(Altova.Types.DateTime dt)             // 1=sunday,...		//{ return (int) dt.Value.DayOfWeek; }
        {
            long a = (14 - dt.Value.Month) / 12;
            long m = dt.Value.Month + 12 * a - 3;
            long y = dt.Value.Year + 4800 - a;

            long JD = dt.Value.Day + (153 * m + 2) / 5 + y * 365 + y / 4 - y / 100 + y / 400 - 32045; // julian date

            return((int)(JD % 7 + 1));
        }
示例#3
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static Altova.Types.DateTime DatetimeFromDateAndTime(Altova.Types.DateTime date, Altova.Types.DateTime time)
 {
     Altova.Types.DateTime ret   = new Altova.Types.DateTime(date);
     System.DateTime       sysdt = ret.Value;
     sysdt     = sysdt.AddHours(-date.Value.Hour + time.Value.Hour);
     sysdt     = sysdt.AddMinutes(-date.Value.Minute + time.Value.Minute);
     sysdt     = sysdt.AddSeconds(-date.Value.Second + time.Value.Second);
     sysdt     = sysdt.AddMilliseconds(-date.Value.Millisecond + time.Value.Millisecond);
     ret.Value = sysdt;
     return(ret);
 }
示例#4
0
文件: Xlsx.cs 项目: soravroyal/EPRTR
        public static double DatetimeToXLSX(Altova.Types.DateTime o)
        {
            Altova.Types.DateTime dt = new Altova.Types.DateTime(o);
            dt.TimezoneOffset = 0;
            double result = TimeToXLSX(dt);

            if (result >= 60)
            {
                result++;
            }

            return(++result);
        }
示例#5
0
文件: Lang.cs 项目: soravroyal/EPRTR
        public static int Weeknumber(Altova.Types.DateTime dt)
        {
            long a = (14 - dt.Value.Month) / 12;
            long m = dt.Value.Month + 12 * a - 3;
            long y = dt.Value.Year + 4800 - a;

            long JD = dt.Value.Day + (153 * m + 2) / 5 + y * 365 + y / 4 - y / 100 + y / 400 - 32045;

            long d4 = (JD + 31741 - (JD % 7)) % 146097 % 36524 % 1461;
            long L  = d4 / 1460;
            long d1 = ((d4 - L) % 365) + L;

            return((int)(d1 / 7 + 1));
        }
示例#6
0
文件: Xlsx.cs 项目: soravroyal/EPRTR
        public static Altova.Types.DateTime XLSXToDate(double o)
        {
            int days = (int)o;

            Altova.Types.DateTime result = new Altova.Types.DateTime(1900, 1, 1);

            days--;

            if (days >= 60)
            {
                days--;
            }

            return(Lang.DatetimeAdd(new Altova.Types.DateTime(1900, 1, 1), new Altova.Types.Duration(0, 0, days, 0, 0, 0, 0.0, false)));
        }
示例#7
0
文件: Lang.cs 项目: soravroyal/EPRTR
        public static Altova.Types.Duration DatetimeDiff(Altova.Types.DateTime a, Altova.Types.DateTime b)
        {
            Altova.Types.Duration dur = new Altova.Types.Duration(a.Value.Ticks - b.Value.Ticks);
            int timezoneOffset        = 0;

            if (a.HasTimezone)
            {
                timezoneOffset -= (int)a.TimezoneOffset;
            }
            if (b.HasTimezone)
            {
                timezoneOffset += (int)b.TimezoneOffset;
            }
            if (timezoneOffset != 0)
            {
                dur.Value = dur.Value.Add(new System.TimeSpan(0, timezoneOffset, 0));
            }
            return(dur);
        }
示例#8
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int MonthFromDatetime(Altova.Types.DateTime dt)
 {
     return(dt.Value.Month);
 }
示例#9
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static bool Numeric(Altova.Types.DateTime dt)
 {
     return(false);
 }
示例#10
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int Timezone(Altova.Types.DateTime dt)
 {
     return(dt.TimezoneOffset);
 }
示例#11
0
文件: Lang.cs 项目: soravroyal/EPRTR
        public static bool Leapyear(Altova.Types.DateTime dt)
        {
            int year = dt.Value.Year;

            return((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
        }
示例#12
0
 public override string Format(DateTime dt)
 {
     return dt.ToString(Altova.Types.DateTimeFormat.W3_time);
 }
示例#13
0
文件: Xlsx.cs 项目: soravroyal/EPRTR
        public static double TimeToXLSX(Altova.Types.DateTime o)
        {
            Altova.Types.Duration diff = Lang.DatetimeDiff(o, new Altova.Types.DateTime(1900, 1, 1));

            return((double)diff.Value.TotalMilliseconds / 86400000.0);
        }
示例#14
0
 public static bool EqualOrLess(Altova.Types.DateTime a, Altova.Types.DateTime b)
 {
     return(a <= b);
 }
示例#15
0
 public static bool Less(Altova.Types.DateTime a, Altova.Types.DateTime b)
 {
     return(a < b);
 }
示例#16
0
 public static string ToString(Altova.Types.DateTime dt)
 {
     return(Altova.CoreTypes.CastToString(dt));
 }
示例#17
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static Altova.Types.DateTime TimeFromDatetime(Altova.Types.DateTime dt)
 {
     return(DatetimeFromParts(1, 1, 1, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond, dt.TimezoneOffset));
 }
示例#18
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static Altova.Types.DateTime DateFromDatetime(Altova.Types.DateTime dt)
 {
     return(DatetimeFromParts(dt.Value.Year, dt.Value.Month, dt.Value.Day, 0, 0, 0, 0.0m, dt.TimezoneOffset));
 }
示例#19
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static Altova.Types.DateTime DatetimeAdd(Altova.Types.DateTime a, Altova.Types.Duration b)
 {
     Altova.Types.DateTime dt = new Altova.Types.DateTime(new System.DateTime(a.Value.AddMonths(b.Years * 12 + b.Months).Ticks + b.Value.Ticks));
     dt.TimezoneOffset = a.TimezoneOffset;
     return(dt);
 }
示例#20
0
 public static bool Greater(Altova.Types.DateTime a, Altova.Types.DateTime b)
 {
     return(a > b);
 }
示例#21
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int DayFromDatetime(Altova.Types.DateTime dt)
 {
     return(dt.Value.Day);
 }
示例#22
0
 public static bool EqualOrGreater(Altova.Types.DateTime a, Altova.Types.DateTime b)
 {
     return(a >= b);
 }
示例#23
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int HourFromDatetime(Altova.Types.DateTime dt)
 {
     return(dt.Value.Hour);
 }
示例#24
0
 public static bool NotEqual(Altova.Types.DateTime a, Altova.Types.DateTime b)
 {
     return(a != b);
 }
示例#25
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int MinuteFromDatetime(Altova.Types.DateTime dt)
 {
     return(dt.Value.Minute);
 }
示例#26
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static int SecondFromDatetime(Altova.Types.DateTime dt)
 {
     return(dt.Value.Second);
 }
示例#27
0
文件: Lang.cs 项目: soravroyal/EPRTR
 public static decimal MillisecondFromDatetime(Altova.Types.DateTime dt)
 {
     return((decimal)dt.Value.Millisecond);
 }
示例#28
0
文件: Xlsx.cs 项目: soravroyal/EPRTR
 public static double DateToXLSX(Altova.Types.DateTime o)
 {
     return(DatetimeToXLSX(o));
 }
示例#29
0
 public virtual string Format(DateTime v)
 {
     return CoreTypes.CastToString(v);
 }