On Sun, Jan 25, 2015 at 5:08 AM, Tal Salman <tal.s...@gmail.com> wrote:
how do i get the current hebrew date and parse it to: year, month, week, day
--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swift-languag...@googlegroups.com.
To post to this group, send email to swift-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/a7076a44-dad9-47fd-a0b0-af7dc1ae39fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There's a handy class called NSCalendar
. You create one like this:
NSCalendar * gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSCalendar * hebrew = [[NSCalendar alloc] initWithCalendarIdentifier:NSHebrewCalendar];
Once you've got the calendar objects, you can use them to convert a date around to various representations:
NSDate * date = [NSDate date];
NSDateComponents * components = [gregorian components:NSUIntegerMax fromDate:date];
NSDate * hebrewDate = [hebrew dateFromComponents:components];
NSLog(@"date: %@", date);
NSLog(@"hebrew: %@", hebrewDate);
let hebrew = NSCalendar(calendarIdentifier: NSHebrewCalendar)
let date = NSDate()
let formatter = NSDateFormatter()
formatter.dateStyle = NSDateFormatterStyle.LongStyle
formatter.timeStyle = NSDateFormatterStyle.ShortStyle
formatter.calendar = hebrew
println(formatter.stringFromDate(date))
this is the result i need:
12 Adar 5775 at 10:04 AM"
thanks man, very helped me