예제 #1
0
        public static bool TryFormat(this System.DateTimeOffset value, Span <char> destination, out int charsWritten, ReadOnlySpan <char> format = default)
        {
            var f    = GetFormat(format);
            var span = ((f == null) ? value.ToString() : value.ToString(f)).AsSpan();

            if (span.TryCopyTo(destination))
            {
                charsWritten = span.Length;
                return(true);
            }
            else
            {
                charsWritten = 0;
                return(false);
            }
        }
예제 #2
0
 // 添加了形参 System.DateTimeOffset set_day,用来表示用户设置的时间
 public TodoItem(string title, string description, System.DateTimeOffset set_day)
 {
     this.id          = Guid.NewGuid().ToString();
     this.title       = title;
     this.description = description;
     this.completed   = false; //默认为未完成
     this.day         = set_day;
     this.date        = set_day.ToString();
 }
예제 #3
0
        public string GetCaptureFilename(System.DateTimeOffset dt, int w, int h)
        {
            // construct output filename
            string time_string   = dt.ToString("(yyyy_MM_dd_hh_mm_ss)");
            string dim           = String.Format("({0}x{1})", w, h);
            string path          = GetCaptureFolder();
            string fname         = "screenshot_" + time_string + "_" + dim + ".png";
            string full_filename = Path.Combine(path, fname);

            return(full_filename);
        }
예제 #4
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a long time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToLongTimeString(this System.DateTimeOffset @this, string culture)
 {
     return(@this.ToString("T", new CultureInfo(culture)));
 }
예제 #5
0
            /* ----------------------------------------------- Functions */
            #region Functions
            public static bool Exec(ref Setting settingBatchImporter,
                                    ref LibraryEditor_SpriteStudio6.Import.Setting settingImportInitial,
                                    string nameFileList,                                                /* Full-Path */
                                    string nameFileLog                                                  /* Full-Path */
                                    )
            {
//				const string messageLogPrefix = "Batch-Importer";

                if (true == string.IsNullOrEmpty(nameFileList))
                {
                    return(false);
                }

                /* Copy Setting (for Overwriting) */
                LibraryEditor_SpriteStudio6.Import.Setting settingImport = settingImportInitial;

                /* Get BaseDirectory (External File) */
#if false
                /* MEMO: Base directory is asset's directory when specify relative path in ListFile. */
//				string nameDirectoryBaseExternal = LibraryEditor_SpriteStudio6.Utility.File.NamePathRootNative;
#else
                /* MEMO: Base directory is ListFile's directory when specify relative path in ListFile. */
                string nameFile;
                string nameExternal;
                LibraryEditor_SpriteStudio6.Utility.File.PathSplit(out NameFolderBaseExternal, out nameFile, out nameExternal, nameFileList);
#endif
                NameFolderBaseExternal = PathNormalizeDelimiter(NameFolderBaseExternal, true);

                NameFolderRootAsset = "/";
                NameFolderRootAsset = PathNormalizeDelimiter(NameFolderRootAsset, true);

                NameBaseFolderSetting = string.Copy(NameFolderBaseExternal);
                NameBaseFolderAsset   = string.Copy(NameFolderRootAsset);
                NameBaseFolderData    = string.Copy(NameFolderBaseExternal);

                /* Set Log-File */
                System.IO.StreamWriter streamLog = null;
                if (false == string.IsNullOrEmpty(nameFileLog))
                {
                    streamLog = new System.IO.StreamWriter(nameFileLog, false, System.Text.Encoding.Default);                           /* Overwrite */
                }
                LibraryEditor_SpriteStudio6.Utility.Log.StreamExternal = streamLog;

                /* Open List-File */
                System.IO.StreamReader streamList = new System.IO.StreamReader(nameFileList, System.Text.Encoding.Default);

                /* Log Date */
                System.DateTimeOffset dateTime = System.DateTimeOffset.Now;
                LibraryEditor_SpriteStudio6.Utility.Log.Message("[Date imported] " + dateTime.ToString(), true, false);                                                   /* External-File only */
                LibraryEditor_SpriteStudio6.Utility.Log.Message("[In charge] " + System.Environment.MachineName + " (" + System.Environment.UserName + ")", true, false); /* External-File only */

                /* Decode List-File (1 Line) */
                Mode = LibraryEditor_SpriteStudio6.Import.Setting.KindMode.SS6PU;
                int    indexLine     = 0;
                string textLine      = "";
                string textLineValid = "";
                bool   flagValid;
                while (0 <= streamList.Peek())
                {
                    /* Read & Trim 1-Line */
                    flagValid = true;
                    textLine  = streamList.ReadLine();
                    indexLine++;
                    switch (LibraryEditor_SpriteStudio6.Utility.ExternalText.TypeGetLine(out textLineValid, textLine))
                    {
                    case LibraryEditor_SpriteStudio6.Utility.ExternalText.KindType.COMMAND:
                        /* Setting Command */
                        flagValid = DecodeCommand(ref settingBatchImporter, ref settingImport, indexLine, textLineValid);
                        break;

                    case LibraryEditor_SpriteStudio6.Utility.ExternalText.KindType.NORMAL:
                        /* File-Name to import */
                        flagValid = ImportFile(ref settingBatchImporter, ref settingImport, indexLine, textLineValid);
                        break;

                    case LibraryEditor_SpriteStudio6.Utility.ExternalText.KindType.IGNORE:
                        /* Remarks */
                        flagValid = true;
                        break;

                    default:
                        LogError("Syntax Error [" + textLine + "]", indexLine);
                        flagValid = false;
                        break;
                    }

                    /* Check Stopping-Processing */
                    if ((false == flagValid) && (false == settingBatchImporter.FlagNotBreakOnError))
                    {
                        return(false);
                    }
                }

                /* Close List-File */
                if (null != streamList)
                {
                    streamList.Close();
                    streamList = null;
                }

                /* Close Log-File */
                if (null != streamLog)
                {
                    streamLog.Close();
                    streamLog = null;
                }
                LibraryEditor_SpriteStudio6.Utility.Log.StreamExternal = null;

                return(true);
            }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a sortable date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToSortableDateTimeOffsetString(this System.DateTimeOffset @this, string culture)
 {
     return(@this.ToString("s", new CultureInfo(culture)));
 }
예제 #7
0
 public static String ToSortString(this DateTimeOffset Me) => Me.ToString("yyyy-MM-dd HH:mm:ss");
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a short date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToShortDateTimeString(this System.DateTimeOffset @this, CultureInfo culture)
 {
     return(@this.ToString("g", culture));
 }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to an universal sortable date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToUniversalSortableDateTimeOffsetString(this System.DateTimeOffset @this, CultureInfo culture)
 {
     return(@this.ToString("u", culture));
 }
예제 #10
0
        private string ExtractTimeAndTimeZone(System.DateTimeOffset localDateTime)
        {
            var value = localDateTime.ToString();

            return(value.Substring(value.Length - 17));
        }
예제 #11
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to an universal sortable long date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToUniversalSortableLongDateTimeString(this System.DateTimeOffset @this, string culture)
 {
     return(@this.ToString("U", new CultureInfo(culture)));
 }
예제 #12
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a rfc 1123 string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToRfc1123String(this System.DateTimeOffset @this)
 {
     return(@this.ToString("r", DateTimeFormatInfo.CurrentInfo));
 }
예제 #13
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a rfc 1123 string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToRfc1123String(this System.DateTimeOffset @this, CultureInfo culture)
 {
     return(@this.ToString("r", culture));
 }
예제 #14
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a month day string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToMonthDayString(this System.DateTimeOffset @this, string culture)
 {
     return(@this.ToString("m", new CultureInfo(culture)));
 }
예제 #15
0
 public static String ToSortShortDateString(this DateTimeOffset Me) => Me.ToString("yyyy-MM-dd");
예제 #16
0
 public static string ToFhirDate(this System.DateTimeOffset me) => me.ToString("yyyy-MM-dd");
예제 #17
0
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a full date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToFullDateTimeOffsetString(this System.DateTimeOffset @this, CultureInfo culture)
 {
     return(@this.ToString("F", culture));
 }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a year month string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <param name="culture">The culture.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToYearMonthString(this System.DateTimeOffset @this, CultureInfo culture)
 {
     return(@this.ToString("y", culture));
 }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to an universal sortable date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToUniversalSortableDateTimeOffsetString(this System.DateTimeOffset @this)
 {
     return(@this.ToString("u", DateTimeFormatInfo.CurrentInfo));
 }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a year month string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToYearMonthString(this System.DateTimeOffset @this)
 {
     return(@this.ToString("y", DateTimeFormatInfo.CurrentInfo));
 }
 /// <summary>
 ///     A DateTimeSet extension method that converts this object to a short date time string.
 /// </summary>
 /// <param name="this">The @this to act on.</param>
 /// <returns>The given data converted to a string.</returns>
 public static string ToShortDateTimeString(this System.DateTimeOffset @this)
 {
     return(@this.ToString("g", DateTimeFormatInfo.CurrentInfo));
 }
예제 #22
0
 /// <summary>
 /// Converts to ISO 8601 date.
 /// </summary>
 /// <param name="dateTimeOffset">The date time offset.</param>
 public static string ToIso8601Date(this DateTimeOffset dateTimeOffset)
 {
     return(dateTimeOffset.ToString(GlobalizationConstants.DateTimeIso8601, GlobalizationConstants.EnglishCultureInfo));
 }