- Timestamp:
- 12/05/16 02:29:50 (8 years ago)
- Location:
- cpp/frams
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genotypeloader.cpp
r635 r639 13 13 { "genotype", 0, 0, "Genotype", "s 1", FIELD(genotype), "Genes as a string of characters.", }, 14 14 15 { "info_timestamp", 1, 0, " Creation time", "fd0 -1 0", FIELD(info_timestamp), },15 { "info_timestamp", 1, 0, "Last modified", "ft 0 -1 0", FIELD(info_timestamp), }, 16 16 { "info_author", 1, 0, "Author name", "s 0 100", FIELD(info_author), }, 17 17 { "info_author_ispublic", 1, 0, "Author name is public", "d 0 1 1", FIELD(info_author_ispublic), }, -
cpp/frams/util/extvalue.cpp
r636 r639 746 746 } 747 747 748 SString ExtValue::format(SString& fmt, const ExtValue **values, int count) 748 SString ExtValue::formatTime(char fmt, double value) 749 { 750 if (fmt=='i') 751 { //could be Convert::ctime() 752 int d,h,m,ti=value; 753 int ms=1000*(value-ti); 754 d=ti/86400; ti-=d*86400; 755 h=ti/3600; ti-=h*3600; 756 m=ti/60; ti-=m*60; 757 SString ret; 758 if (d>0) ret+=SString::sprintf("%dd ",d); 759 if (h>0) ret+=SString::sprintf("%d:",h); 760 ret+=SString::sprintf("%02d:%02d.%03d", m,ti,ms); 761 return ret; 762 } 763 time_t ti = value; 764 struct tm tm = Convert::localtime(ti); 765 switch(fmt) 766 { 767 case 'T': return SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 768 case 't': return SString(Convert::asctime(tm).c_str()); 769 case 'y': return SString::sprintf("%04d-%02d-%02d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday); 770 case 'm': return SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d.%03d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, int(1000*(value-(double)ti))); 771 } 772 return SString(); 773 } 774 775 SString ExtValue::format(const SString& fmt, const ExtValue **values, int count) 749 776 { 750 777 SString ret; … … 788 815 case 'f': case 'g': case 'e': type = 'f'; t = next; break; 789 816 case 's': type = 's'; t = next; break; 790 case 't': case 'T': type = *t; t = next; break;817 case 't': case 'T': case 'y': case 'i': case 'm': type = *t; t = next; break; 791 818 case '%': if (t > begin) { type = *t; t = next; } break; 792 819 } … … 805 832 case 'f': a = args.getNext(); ret += SString::sprintf(sub.c_str(), a ? a->getDouble() : 0); break; 806 833 case 's': {a = args.getNext(); SString tmp; if (a) tmp = a->getString(); ret += SString::sprintf(sub.c_str(), tmp.c_str()); } break; 807 case 't': case 'T': 808 { 834 case 't': case 'T': case 'i': case 'y': case 'm': 809 835 a = args.getNext(); 810 time_t ti = a ? a->getInt() : 0; 811 struct tm tm = Convert::localtime(ti); 812 SString timtxt; 813 if (type == 'T') 814 timtxt = SString::sprintf("%04d-%02d-%02d %02d:%02d:%02d", 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 815 else 816 timtxt = Convert::asctime(tm).c_str(); 817 ret += timtxt; 836 ret += formatTime(type,a ? a->getDouble() : 0); 818 837 ret += sub.substr(2); 819 }820 838 break; 821 839 case '%': ret += '%'; ret += sub.substr(2); break; -
cpp/frams/util/extvalue.h
r636 r639 219 219 }; 220 220 221 static SString format(SString& fmt, const ExtValue **values, int count); 221 static SString formatTime(char fmt, double value); 222 static SString format(const SString& fmt, const ExtValue **values, int count); 222 223 223 224 ExtValue getExtType();
Note: See TracChangeset
for help on using the changeset viewer.