Miscellany
public text v1 · immutable#import <stdio.h>
#import <time.h>
#import "Swatch.h"
@implementation Swatch
-(float) beats {
time_t timer=time(NULL);
struct tm *g;
g=gmtime(&timer);
int hour=g->tm_hour, min=g->tm_min, sec=g->tm_sec;
int utc=hour*3600+min*60+sec; // Greenwich, England
int bmt=utc+3600; // Biel, Switzerland
float beat=bmt/86.4;
if (beat>1000)
beat-=1000;
return beat;
}
-(NSString*) swatch {
return [NSString stringWithFormat:@"@%06.2f", [self beats]];
}
@end