タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

timeとrubyに関するjune29のブックマーク (3)

  • strptime gemで高速に文字列をTimeに変換する - Qiita

    背景 Rubyで文字列の時間表現を時間に変換するにはTime.strptimeをよく使います.以下は公式リファレンスの例です. Time.strptime('2001-02-03T04:05:06+09:00', '%Y-%m-%dT%H:%M:%S%z') #=> 2001-02-03 06:05:06 +0900 これは楽でとても便利なんですが,Time.strptimeには遅いという致命的な問題があります.例えばFluentdのようなひたすらログを読み込んでパースするソフトウェアの場合,Time.strptimeそのものがボトルネックになります.これはTime.strptimeは毎回文字列フォーマットをパースしないといけないなど,いくつかの要因があります. Fluentdでこの問題をどう解決していたかと言うと,文字列をキャッシュして,前と文字列が同じであればTime.strptime

    strptime gemで高速に文字列をTimeに変換する - Qiita
  • RubyとRailsにおけるTime, Date, DateTime, TimeWithZoneの違い - Qiita

    RubyRailsにおけるTime, Date, DateTime, TimeWithZoneの違いRubyRails 2021.2.11追記:DateTimeクラスは非推奨なクラスになりました DateTimeクラスは非推奨なクラスとなり、DateTimeクラスではなくTimeクラスを使うよう、公式にアナウンスされました。 参考1 But we consider use of DateTime should be discouraged. - matz (Yukihiro Matsumoto) https://bugs.ruby-lang.org/issues/15712#note-4 参考2 DateTime は deprecated とされているため、 Timeを使うことを推奨します。 https://docs.ruby-lang.org/ja/latest/class/DateT

    RubyとRailsにおけるTime, Date, DateTime, TimeWithZoneの違い - Qiita
    june29
    june29 2015/06/07
    ややこしすぎる〜
  • For a Good Strftime - Easy Skeezy Ruby Date/Time Formatting

    Seconds %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) %s - Number of seconds since 1970-01-01 00:00:00 UTC. Minutes %M - Minute of the hour (00..59) Hours %H - Hour of the day, 24-hour clock (00..23) %I - Hour of the day, 12-hour clock (01..12) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %l - Hour of the day, 12-hour clock, blank-padded ( 0..12) Days %

    june29
    june29 2010/12/21
    strftime を使うときに便利。
  • 1