| 1 | #Region "Microsoft.VisualBasic::95c0389556069ba41fb6ed123521cb16, Microsoft.VisualBasic.Core\ComponentModel\TimeSpan.vb" |
| 2 | |
| 3 | ' Author: |
| 4 | ' |
| 5 | ' asuka (amethyst.asuka@gcmodeller.org) |
| 6 | ' xie (genetics@smrucc.org) |
| 7 | ' xieguigang (xie.guigang@live.com) |
| 8 | ' |
| 9 | ' Copyright (c) 2018 GPL3 Licensed |
| 10 | ' |
| 11 | ' |
| 12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
| 13 | ' |
| 14 | ' |
| 15 | ' This program is free software: you can redistribute it and/or modify |
| 16 | ' it under the terms of the GNU General Public License as published by |
| 17 | ' the Free Software Foundation, either version 3 of the License, or |
| 18 | ' (at your option) any later version. |
| 19 | ' |
| 20 | ' This program is distributed in the hope that it will be useful, |
| 21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ' GNU General Public License for more details. |
| 24 | ' |
| 25 | ' You should have received a copy of the GNU General Public License |
| 26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | |
| 29 | |
| 30 | ' /********************************************************************************/ |
| 31 | |
| 32 | ' Summaries: |
| 33 | |
| 34 | ' Structure TimeInterval |
| 35 | ' |
| 36 | ' Properties: Days, Hours, Miliseconds, Minutes, Seconds |
| 37 | ' Ticks, TimeSpan |
| 38 | ' |
| 39 | ' Constructor: (+1 Overloads) Sub New |
| 40 | ' Function: ToString |
| 41 | ' |
| 42 | ' |
| 43 | ' /********************************************************************************/ |
| 44 | |
| 45 | #End Region |
| 46 | |
| 47 | Imports System.Runtime.CompilerServices |
| 48 | Imports System.Xml.Serialization |
| 49 | |
| 50 | |
| 51 | Namespace ComponentModel |
| 52 | |
| 53 | <XmlTypeAttribute("Interval", Namespace:="Microsoft.VisualBasic/Numerical_DataStruct")> |
| 54 | Public Structure TimeInterval |
| 55 | |
| 56 | <XmlAttribute("dd")> Public Property Days As Integer |
| 57 | <XmlAttribute("min")> Public Property Minutes As Integer |
| 58 | <XmlAttribute("hr")> Public Property Hours As Integer |
| 59 | <XmlAttribute("ss")> Public Property Seconds As Integer |
| 60 | <XmlAttribute("ms")> Public Property Miliseconds As Integer |
| 61 | |
| 62 | Sub New(TimeSpan As TimeSpan) |
| 63 | Days = TimeSpan.Days |
| 64 | Minutes = TimeSpan.Minutes |
| 65 | Hours = TimeSpan.Hours |
| 66 | Seconds = TimeSpan.Seconds |
| 67 | Miliseconds = TimeSpan.Milliseconds |
| 68 | End Sub |
| 69 | |
| 70 | Public ReadOnly Property TimeSpan As TimeSpan |
| 71 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
| 72 | Get |
| 73 | Return New TimeSpan(Days, Hours, Minutes, Seconds, Miliseconds) |
| 74 | End Get |
| 75 | End Property |
| 76 | |
| 77 | ''' <summary> |
| 78 | ''' (dd hh:mm:ss) 输出可以被MySQL数据库所识别的字符串格式 |
| 79 | ''' </summary> |
| 80 | ''' <returns></returns> |
| 81 | ''' <remarks></remarks> |
| 82 | Public Overrides Function ToString() As String |
| 83 | Return String.Format("{0} {1}:{2}:{3}", Days, Hours, Minutes, Seconds) |
| 84 | End Function |
| 85 | |
| 86 | Public ReadOnly Property Ticks As Long |
| 87 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
| 88 | Get |
| 89 | Return TimeSpan.Ticks |
| 90 | End Get |
| 91 | End Property |
| 92 | |
| 93 | Public Shared Widening Operator CType(TimeSpan As TimeSpan) As TimeInterval |
| 94 | Return New TimeInterval(TimeSpan) |
| 95 | End Operator |
| 96 | End Structure |
| 97 | End Namespace |