Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
45
Task/Date-manipulation/FutureBasic/date-manipulation.basic
Normal file
45
Task/Date-manipulation/FutureBasic/date-manipulation.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
void local fn DoIt
|
||||
CFStringRef monthString, zoneString, ampmString
|
||||
long month, day, year, hour, minute
|
||||
|
||||
CFStringRef dateString = @"March 7 2009 7:30pm EST"
|
||||
|
||||
DateFormatterRef df = fn DateFormatterInit
|
||||
DateFormatterSetDateStyle( df, NSDateFormatterMediumStyle )
|
||||
DateFormatterSetTimeStyle( df, NSDateFormatterMediumStyle )
|
||||
DateFormatterSetDateFormat( df, @"MMMM d YYYY h:ma" )
|
||||
|
||||
CFArrayRef months = fn DateFormatterMonthSymbols( df )
|
||||
CFCharacterSetRef spaceSet = fn CharacterSetWhitespaceSet
|
||||
|
||||
ScannerRef scanner = fn ScannerWithString( dateString )
|
||||
ScannerSetCharactersToBeSkipped( scanner, fn CharacterSetWithCharactersInString(@": ") )
|
||||
|
||||
fn ScannerScanUpToCharactersFromSet( scanner, spaceSet, @monthString )
|
||||
fn ScannerScanInteger( scanner, @day )
|
||||
fn ScannerScanInteger( scanner, @year )
|
||||
fn ScannerScanInteger( scanner, @hour )
|
||||
fn ScannerScanInteger( scanner, @minute )
|
||||
fn ScannerScanUpToCharactersFromSet( scanner, spaceSet, @ampmString )
|
||||
fn ScannerScanUpToCharactersFromSet( scanner, spaceSet, @zoneString )
|
||||
|
||||
month = fn ArrayIndexOfObject( months, monthString ) + 1
|
||||
if ( fn StringIsEqual( ampmString, @"pm" ) ) then hour += 12
|
||||
|
||||
DateComponentsRef comps = fn DateComponentsInit
|
||||
DateComponentsSetMonth( comps, month )
|
||||
DateComponentsSetDay( comps, day )
|
||||
DateComponentsSetYear( comps, year )
|
||||
DateComponentsSetHour( comps, hour + 12 )
|
||||
DateComponentsSetMinute( comps, minute )
|
||||
|
||||
CFDateRef dt = fn CalendarDateFromComponents( fn CalendarCurrent, comps )
|
||||
CFStringRef string = fn DateFormatterStringFromDate( df, dt )
|
||||
string = fn StringByAppendingFormat( string, @" %@", zoneString )
|
||||
|
||||
print string
|
||||
end fn
|
||||
|
||||
fn DoIt
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue