タグ

日時に関するJHashimotoのブックマーク (3)

  • JavaScript の Date は罠が多すぎる - Qiita

    JavaScript で日付・時間を扱っていて、次から次へと罠にはまったので、あとから来る人のために書き留めておく。 Date.parse が返すのは Date でなく整数 Date.parse は、世界協定時 1970 年 1 月 1 日 00:00:00 からの経過時間をミリ秒単位で返す。 Date を得るには new Date に渡す。 new Date に直接文字列渡しても同じ挙動なので、こちらのが簡潔。 msec = Date.parse("Thu, 06 Sep 2012 00:00:00 +0900"); // 1346857200000 date = new Date(msec); // Date date = new Date("Thu, 06 Sep 2012 00:00:00 +0900"); // Date

    JavaScript の Date は罠が多すぎる - Qiita
  • Noda Time | Date and time API for .NET

    Noda Time is an alternative date and time API for .NET. It helps you to think about your data more clearly, and express operations on that data more precisely. // Instant represents time from epoch Instant now = SystemClock.Instance.GetCurrentInstant(); // Convert an instant to a ZonedDateTime ZonedDateTime nowInIsoUtc = now.InUtc(); // Create a duration Duration duration = Duration.FromMinutes(3)

  • C#のDateTime型に月初日や月末日を取得するメソッドを追加する - Qiita

    業務用のアプリケーションを作成していると、何かと日付の比較をすることが多くて、その中である年月の月初日や月末日が必要になることもままあります。 残念ながらc#のDateTime型には月初日や月末日を求めるメソッドは用意されていないので、サンプルコードのような日時関連の処理をまとめた拡張メソッドを作って利用してます。 サンプルコード /// <summary> /// DateTime型拡張メソッド定義 /// </summary> public static class DateTimeUtil { private static readonly int FiscalYearStartingMonth = 4; /// <summary> /// 該当年月の日数を返す /// </summary> /// <param name="dt">DateTime</param> /// <ret

    C#のDateTime型に月初日や月末日を取得するメソッドを追加する - Qiita
    JHashimoto
    JHashimoto 2015/05/07
    “業務用のアプリケーションを作成していると、何かと日付の比較をすることが多くて、その中である年月の月初日や月末日が必要になることもままあります。"”
  • 1