예제 #1
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public static JwTime CreateTime(int hh, int mm, int ss, int ms)
 {
     JwTime t;
     t = new JwTime();
     t.Set(hh, mm, ss, ms);
     return t;
 }
예제 #2
0
        //# __________ PROTOCOL :: FORMAT __________ #//
        /**
         * I provide a very simple, and non-optimized, facility for formatting
         * dates in a variety of formats.  Valid format codes are:
         * {H}    : hour (1-12)
         * {HH}   : hour (01-12)
         * {H24}  : hour (0-23)
         * {HH24} : hour (00-23)
         * {M}    : minute (0-59)
         * {MM}   : minute (00-59)
         * {S}    : second (0-59)
         * {SS}   : second (00-59)
         * {MS}   : millisecond (000-999)
         * {am/pm}: am/pm (am, pm)
         */
        public static String Format(JwTime e, String format)
        {
            if ( e == null )
                return null;

            String s = format;
            s = JwUtility.ReplaceAll(s, "{H}",      e.GetHour12()+"");
            s = JwUtility.ReplaceAll(s, "{HH}",     Pad2(e.GetHour12()));
            s = JwUtility.ReplaceAll(s, "{H24}",    e.GetHour()+"");
            s = JwUtility.ReplaceAll(s, "{HH24}",   Pad2(e.GetHour()));

            s = JwUtility.ReplaceAll(s, "{M}",      e.GetMinute()+"");
            s = JwUtility.ReplaceAll(s, "{MM}",     Pad2(e.GetMinute()));

            s = JwUtility.ReplaceAll(s, "{S}",      e.GetSecond()+"");
            s = JwUtility.ReplaceAll(s, "{SS}",     Pad2(e.GetSecond()));

            s = JwUtility.ReplaceAll(s, "{MS}",     Pad3(e.GetMillisecond()));

            s = JwUtility.ReplaceAll(s, "{/p}",     e.IsAm() ? ""   : "p");
            s = JwUtility.ReplaceAll(s, "{/pm}",    e.IsAm() ? ""   : "pm");
            s = JwUtility.ReplaceAll(s, "{a/p}",    e.IsAm() ? "a"  : "p");
            s = JwUtility.ReplaceAll(s, "{A/P}",    e.IsAm() ? "A"  : "P");
            s = JwUtility.ReplaceAll(s, "{am/pm}",  e.IsAm() ? "am" : "pm");
            s = JwUtility.ReplaceAll(s, "{AM/PM}",  e.IsAm() ? "AM" : "PM");
            return s;
        }
예제 #3
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public static JwTime CreateNowUtc()
 {
     JwTime t;
     t = new JwTime();
     t.SetNowUtc();
     return t;
 }
예제 #4
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public static JwTime CreateTime(DateTime dt)
 {
     // kludge (err) - need to learn how to check DateTime for empty
     //if ( dt == null ) return null;
     JwTime t = new JwTime();
     t.Set(dt);
     return t;
 }
예제 #5
0
 //# __________ PROTOCOL :: INSTANCE CREATION __________ #//
 public static JwTimestamp CreateTimestamp(JwDate d, JwTime t)
 {
     JwTimestamp ts;
     ts = new JwTimestamp();
     ts.SetDate(d);
     ts.SetTime(t);
     return ts;
 }
예제 #6
0
 //# __________ PROTOCOL :: INSTANCE CREATION __________ #//
 public static JwTimeInterval CreateTimeInterval(JwTime start, JwTime end)
 {
     JwTimeInterval ti;
     ti = new JwTimeInterval();
     ti.SetStart(start);
     ti.SetEnd(end);
     return ti;
 }
예제 #7
0
        //# __________ PROTOCOL :: FORMAT __________ #//
        public static String Format_h_mm_am(JwTime t)
        {
            if ( t == null )
                return null;

            int hh = t.GetHour();
            int mm = t.GetMinute();
            String suffix = AM;
            if ( t.IsPm() )
            {
                hh -= 12;
                suffix = PM;
            }
            if ( hh == 0 ) hh = 12;
            return hh + COLON + Pad2(mm) + suffix;
        }
예제 #8
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 //# __________ PROTOCOL :: COPY __________ #//
 public JwTime GetTimeCopy()
 {
     JwTime e;
     e = new JwTime();
     e.SetOrdinal(_ordinal);
     return e;
 }
예제 #9
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public JwDuration Difference(JwTime t)
 {
     long a = GetOrdinal();
     long b = t.GetOrdinal();
     long c = Math.Abs(a-b);
     JwDuration e = new JwDuration();
     e.SetOrdinal(c);
     return e;
 }
예제 #10
0
 public void SetEnd(JwTime t)
 {
     _end = t;
 }
예제 #11
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public bool IsOnOrBefore(JwTime d)
 {
     return CompareTo(d) <= 0;
 }
예제 #12
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 /**
  * Determine if I am between the start and end time, also return true
  * if I am equal to either the start or end time.
  */
 public bool IsBetweenInclusive(JwTime start, JwTime end)
 {
     if ( start != null && IsBefore(start) ) return false;
     if ( end   != null && IsAfter(end) )    return false;
     return true;
 }
예제 #13
0
 public String format(JwTime t)
 {
     return _formatter.Format(t);
 }
예제 #14
0
 //# __________ PROTOCOL :: CONSTRUCTOR __________ #//
 public JwTimestamp()
 {
     _date = new JwDate();
     _time = new JwTime();
 }
예제 #15
0
 public void SetTime(JwTime e)
 {
     _time = e;
 }
예제 #16
0
 /**
  * Determine if this interval contains the time.  The test excludes
  * the start and end dates.
  */
 public bool ContainsExclusive(JwTime t)
 {
     if ( t == null ) return false;
     if ( HasStart()  && GetStart().IsOnOrAfter(t) ) return false;
     if ( HasEnd()    && GetEnd().IsOnOrBefore(t) )  return false;
     return true;
 }
예제 #17
0
 //# __________ PROTOCOL :: INTERSECTION __________ #//
 /**
  * @see containsInclusive
  */
 public bool Contains(JwTime t)
 {
     return ContainsInclusive(t);
 }
예제 #18
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public bool IsAfter(JwTime d)
 {
     return CompareTo(d) > 0;
 }
예제 #19
0
 public void SetStart(JwTime t)
 {
     _start = t;
 }
예제 #20
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 //# __________ PROTOCOL :: COMPARE (convenience) __________ #//
 public bool IsBefore(JwTime d)
 {
     return CompareTo(d) < 0;
 }
예제 #21
0
 //# __________ PROTOCOL :: STATIC __________ #//
 public static String FormatTime(JwTime time, String format)
 {
     JwTimeFormatter tf = new JwTimeFormatter(format);
     return tf.Format(time);
 }
예제 #22
0
파일: JwTime.cs 프로젝트: pabplanalp/pvmail
 public bool IsOnOrAfter(JwTime d)
 {
     return CompareTo(d) >= 0;
 }
예제 #23
0
 public bool HasStart(JwTime t)
 {
     return JwUtility.IsEqual(GetStart(), t);
 }
예제 #24
0
 public String formatHoursAndMinutes(JwTime t)
 {
     return _shortFormatter.Format(t);
 }
예제 #25
0
 //# __________ PROTOCOL :: CONTRUCTOR __________ #//
 public JwTimeInterval()
 {
     _start = null;
     _end = null;
 }
예제 #26
0
        public static String Format_h_mm_ss_msss(JwTime t)
        {
            if ( t == null )
                return null;

            int hh = t.GetHour();
            int mm = t.GetMinute();
            int ss = t.GetSecond();
            int ms = t.GetMillisecond();
            return hh + COLON + Pad2(mm) + COLON + Pad2(ss) + DOT + Pad3(ms);
        }
예제 #27
0
        public static String Format_h_mm_ss_msss_am(JwTime t)
        {
            if ( t == null )
                return null;

            int hh = t.GetHour();
            int mm = t.GetMinute();
            int ss = t.GetSecond();
            int ms = t.GetMillisecond();
            String suffix = AM;
            if ( t.IsPm() )
            {
                hh -= 12;
                suffix = PM;
            }
            if ( hh == 0 ) hh = 12;
            return hh + COLON + Pad2(mm) + COLON + Pad2(ss) + DOT + Pad3(ms) + suffix;
        }
예제 #28
0
 //# __________ PROTOCOL :: FORMAT __________ #//
 public String Format(JwTime e)
 {
     return JwTimeUtility.Format(e, _format);
 }
예제 #29
0
 public bool HasEnd(JwTime t)
 {
     return JwUtility.IsEqual(GetEnd(), t);
 }